[jrubyscripting] Filter out empty require options (#12386)

Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
jimtng 2022-03-01 03:09:57 +10:00 committed by GitHub
parent 6c25e8b528
commit 166e4ec1b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

@ -198,16 +198,16 @@ public class JRubyScriptEngineConfiguration {
return;
}
String[] scripts = requireConfigElement.getValue().get().split(",");
for (String script : scripts) {
final String requireStatement = String.format("require '%s'", script.trim());
Stream.of(requireConfigElement.getValue().get().split(",")).map(s -> s.trim()).filter(s -> !s.isEmpty())
.forEach(script -> {
final String requireStatement = String.format("require '%s'", script);
try {
logger.trace("Injecting require statement: {}", requireStatement);
engine.eval(requireStatement);
} catch (ScriptException e) {
logger.warn("Error evaluating statement {}: {}", requireStatement, e.getMessage());
}
}
});
}
/**