Unverified Commit 57a04648 authored by Georg Weiss's avatar Georg Weiss Committed by GitHub
Browse files

Merge pull request #2266 from ControlSystemStudio/log_properties_fix

Added null pointer check for classpath case
parents 5ed0ed56 0f8ff203
Pipeline #113185 passed with stage
in 16 minutes and 7 seconds
......@@ -28,6 +28,7 @@ import java.net.URI;
import java.net.URL;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
......@@ -61,21 +62,26 @@ public class LogPropertiesController {
}
else if(url.startsWith("classpath:")){
final URL resource = getClass().getResource(url.substring("classpath:".length()));
url = resource.toExternalForm();
// Null pointer check here as the path may be incorrect
if(resource == null){
logger.log(Level.WARNING, "Log properties attribute URL " + url + " is invalid");
}
else{
url = resource.toExternalForm();
}
}
try (InputStream input = new URL(url).openStream() ) {
Properties prop = new Properties();
prop.load(input);
prop.stringPropertyNames().stream().forEach((p) -> {
attributeTypes.put(p.toLowerCase(), prop.getProperty(p).toLowerCase());
}
attributeTypes.put(p.toLowerCase(), prop.getProperty(p).toLowerCase());
}
);
} catch (IOException ex) {
ex.printStackTrace();
logger.log(Level.WARNING, "Unable to load log properties attribute mapping");
}
// create the property trees
name.setMaxWidth(1f * Integer.MAX_VALUE * 40);
name.setCellValueFactory(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment