Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,9 @@ public void modifyConfiguration(ServiceReference<?> reference, Dictionary<String
properties.put(key, values);
} else {
value = InterpolationHelper.substVars(value, null,null, convertDictionaryToMap(properties));
try {
int intValue = Integer.parseInt(value);
properties.put(key, intValue);
} catch (NumberFormatException e) {
if (properties.get(key) != null && (properties.get(key) instanceof Number)) {
properties.put(key, Integer.parseInt(value));
} else {
properties.put(key, value);
}
}
Expand All @@ -66,14 +65,12 @@ public void modifyConfiguration(ServiceReference<?> reference, Dictionary<String
properties.put(key, values);
} else {
value = InterpolationHelper.substVars(value, null,null, convertDictionaryToMap(properties));
try {
int intValue = Integer.parseInt(value);
properties.put(key, intValue);
} catch (NumberFormatException e) {
if (properties.get(key) != null && (properties.get(key) instanceof Number)) {
properties.put(key, Integer.parseInt(value));
} else {
properties.put(key, value);
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,19 @@ public class KarafConfigurationPluginTest {
@Test
public void testSystemProperty() throws Exception {
System.setProperty("org.apache.karaf.shell.sshPort", "8102");
System.setProperty("org.apache.karaf.shell.sshPorts", "[8102,8103]");
KarafConfigurationPlugin plugin = new KarafConfigurationPlugin();
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(Constants.SERVICE_PID, "org.apache.karaf.shell");
properties.put("foo", "bar");
properties.put("sshPort", 8101);
properties.put("sshPorts", new String[] { "8102" });
plugin.modifyConfiguration(null, properties);

Assert.assertEquals(8102, properties.get("sshPort"));
Assert.assertEquals(2, ((String[])properties.get("sshPorts")).length);
Assert.assertEquals("8102", ((String[])properties.get("sshPorts"))[0]);
Assert.assertEquals("8103", ((String[])properties.get("sshPorts"))[1]);
Assert.assertEquals("bar", properties.get("foo"));
}

Expand Down