From 5929c828c0ba1422df9959651acc6d4134e262dc Mon Sep 17 00:00:00 2001 From: Luca Roffia Date: Wed, 17 Jul 2024 12:15:20 +0200 Subject: [PATCH] fix: environmental variables with . or _ --- .../wot/sepa/commons/properties/SPARQL11Properties.java | 4 ++++ .../java/it/unibo/arces/wot/sepa/engine/core/Engine.java | 2 +- .../unibo/arces/wot/sepa/engine/core/EngineProperties.java | 6 ++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/properties/SPARQL11Properties.java b/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/properties/SPARQL11Properties.java index a99466bb..5764cdb2 100644 --- a/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/properties/SPARQL11Properties.java +++ b/client-api/src/main/java/it/unibo/arces/wot/sepa/commons/properties/SPARQL11Properties.java @@ -241,6 +241,10 @@ protected Reader getReaderFromUri(String uri) throws SEPAPropertiesException { } catch (FileNotFoundException ex) { Logging.logger.warn("Failed to get file reader: "+ex.getMessage()); Logging.logger.info("Get resource from URI: "+uri); + if (getClass().getClassLoader().getResourceAsStream(uri) == null) { + Logging.logger.fatal("Resource not found: "+uri); + throw new SEPAPropertiesException("Resource not found: "+uri); + } in = new InputStreamReader(Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(uri))); } } diff --git a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/Engine.java b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/Engine.java index 4c61aadf..3506eb1f 100644 --- a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/Engine.java +++ b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/Engine.java @@ -41,7 +41,7 @@ */ public class Engine implements EngineMBean { - private final static String version = "v0.15.3"; + private final static String version = "v0.15.4"; private EngineProperties properties = null; diff --git a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/EngineProperties.java b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/EngineProperties.java index bcb815a8..6c17e2a1 100644 --- a/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/EngineProperties.java +++ b/engine/src/main/java/it/unibo/arces/wot/sepa/engine/core/EngineProperties.java @@ -311,8 +311,9 @@ public EngineProperties(String[] args) throws SEPASecurityException { try { endpointProperties = new SPARQL11Properties(endpointJpar); } catch (SEPAPropertiesException e) { - Logging.logger.error("Endpoint configuration file not found: "+endpointJpar+"USING DEFAULTS: Jena in memory"); - endpointProperties = new SPARQL11Properties("in-memory",ProtocolScheme.jena_api); + Logging.logger.fatal("Endpoint configuration file not found: "+endpointJpar); + System.exit(-1); + //endpointProperties = new SPARQL11Properties("in-memory",ProtocolScheme.jena_api); } parsingArgument(args); @@ -606,6 +607,7 @@ private void parsingArgument(String[] args) throws PatternSyntaxException { for(String var : envs.keySet()) { Logging.logger.trace("Environmental variable "+var+" : "+envs.get(var)); setParameter("-"+var, envs.get(var)); + setParameter("-"+var.replace("_", "."), envs.get(var)); } }