mirror of
https://github.com/danieldemus/openhab-core.git
synced 2025-01-10 21:31:53 +01:00
Fix IndexOutOfBoundsException in ScriptEngineFactoryHelper (#3549)
* Fix IndexOutOfBoundsException in ScriptEngineFactoryHelper Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
This commit is contained in:
parent
4f2af88e73
commit
5d46377d22
@ -59,9 +59,14 @@ public class ScriptEngineFactoryHelper {
|
||||
}
|
||||
|
||||
public static String getPreferredMimeType(ScriptEngineFactory factory) {
|
||||
List<String> mimeTypes = new ArrayList<>(factory.getScriptTypes());
|
||||
List<String> scriptTypes = factory.getScriptTypes();
|
||||
if (scriptTypes.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
factory.getClass().getName() + " does not support any scriptTypes. Please report it as a bug.");
|
||||
}
|
||||
List<String> mimeTypes = new ArrayList<>(scriptTypes);
|
||||
mimeTypes.removeIf(mimeType -> !mimeType.contains("application") || "application/python".equals(mimeType));
|
||||
return mimeTypes.isEmpty() ? factory.getScriptTypes().get(0) : mimeTypes.get(0);
|
||||
return mimeTypes.isEmpty() ? scriptTypes.get(0) : mimeTypes.get(0);
|
||||
}
|
||||
|
||||
public static String getLanguageName(javax.script.ScriptEngineFactory factory) {
|
||||
|
Loading…
Reference in New Issue
Block a user