diff --git a/src/main/java/ai/apptuit/metrics/jinsight/ConfigService.java b/src/main/java/ai/apptuit/metrics/jinsight/ConfigService.java index 3346d90..7732a1a 100644 --- a/src/main/java/ai/apptuit/metrics/jinsight/ConfigService.java +++ b/src/main/java/ai/apptuit/metrics/jinsight/ConfigService.java @@ -215,12 +215,13 @@ private static Map loadSystemProperties() { } private static String getProperty(String propertyName) { + String updatedPropertyName = propertyName; if(!propertyName.contains(".")) { - propertyName = "jinsight." + propertyName; + updatedPropertyName = "jinsight." + propertyName; } - String propertyValue = System.getenv(propertyName); + String propertyValue = System.getenv(updatedPropertyName); if(propertyValue == null || propertyValue.equals("")){ - propertyValue = System.getProperty(propertyName); + propertyValue = System.getProperty(updatedPropertyName); } return propertyValue != null && !propertyValue.equals("") ? propertyValue : null; } diff --git a/src/test/java/ai/apptuit/metrics/jinsight/ConfigServiceTest.java b/src/test/java/ai/apptuit/metrics/jinsight/ConfigServiceTest.java index 5776048..d765e4a 100644 --- a/src/test/java/ai/apptuit/metrics/jinsight/ConfigServiceTest.java +++ b/src/test/java/ai/apptuit/metrics/jinsight/ConfigServiceTest.java @@ -322,6 +322,7 @@ public void testAgentVersion() throws Exception { assertEquals(System.getProperty("project.version"), cs.getAgentVersion()); } + @SuppressWarnings("all") @Test public void testLoadSystemProperties() throws Exception { // setup here since ConfigService.getInstance() has been initialized in several tests @@ -335,7 +336,6 @@ public void testLoadSystemProperties() throws Exception { initialize(); ConfigService cs = ConfigService.getInstance(); - assertEquals("APPTUIT", cs.getReporterType().name()); assertEquals("TEST_TOKEN", cs.getApiToken()); assertEquals("http://api.test.bicycle.io", cs.getApiUrl().toString()); @@ -350,17 +350,10 @@ public void testLoadSystemProperties() throws Exception { doPrivilegedAction(); } - private void doPrivilegedAction() { - AccessController.doPrivileged((PrivilegedAction) () -> { - try { - Field singletonField = ConfigService.class.getDeclaredField("singleton"); - singletonField.setAccessible(true); - singletonField.set(null, null); - return ""; - } catch (ReflectiveOperationException | SecurityException e) { - throw new RuntimeException(e); - } - }); + private void doPrivilegedAction() throws Exception { + Field singletonField = ConfigService.class.getDeclaredField("singleton"); + singletonField.setAccessible(true); + singletonField.set(null, null); }