-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
Hi Tobias,
From my point of view, the InputStream should be closed once the Properties have been loaded.:
private static ServiceImplementation getServiceImplementationByProperty(ServiceImplementation previousConfig, ${ simpleName } serviceImpl) {
// first try to get config from property file
final String propertyFileName = "/META-INF/spiap/" + ${ simpleName }.class.getCanonicalName() + "/" + serviceImpl.getClass().getCanonicalName() + ".properties";
InputStream inputStream = ${ simpleName }ServiceLocator.class.getResourceAsStream(propertyFileName);
if (inputStream != null) {
try {
Properties properties = new Properties();
properties.load(inputStream);
String id = properties.getProperty("${constants.id}");
String description = properties.getProperty("${constants.description}");
Integer priority = null;
try {
String priorityString = properties.getProperty("${constants.priority}");
if (priorityString != null) {
priority = Integer.valueOf(priorityString);
}
} catch (NumberFormatException e) {
// ignore
}
Boolean outOfService = null;
String outOfServiceString = properties.getProperty("${constants.outOfService}");
if (outOfServiceString != null) {
outOfService = Boolean.valueOf(outOfServiceString);
}
return new ServiceImplementation(previousConfig, id, description, priority, outOfService);
} catch (Exception e) {
// do nothing
}
}
return previousConfig;
}Metadata
Metadata
Assignees
Labels
No labels