Skip to content

Commit d2ab3f8

Browse files
Release 1.2.1: Fixes potential null pointer dereference
1 parent 9874583 commit d2ab3f8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/main/java/com/teragrep/jla_04/RelpHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@ private void initialize(String name) throws NoSuchFieldException, IOException, T
6565

6666
private void initFormatter(String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
6767
String formatter_value = System.getProperty("java.util.logging.RelpHandler." + name + ".formatter");
68-
if (formatter_value != null) {
69-
Object formatter_object = ClassLoader.getSystemClassLoader().loadClass(formatter_value).newInstance();
68+
ClassLoader classloader = ClassLoader.getSystemClassLoader();
69+
if(classloader == null) {
70+
System.out.println("Unable to initialize ClassLoader.getSystemClassLoader(), defaulting to SimpleFormatter");
71+
}
72+
if (classloader != null && formatter_value != null) {
73+
Object formatter_object = classloader.loadClass(formatter_value).newInstance();
7074
this.formatter = (Formatter) formatter_object;
7175
}
7276
else {

0 commit comments

Comments
 (0)