Skip to content

Commit 46246e9

Browse files
Null Handling for EventType Supplier
Applicable to the Log4JLoggerFactory (SPI), in order for the API to remain consistent the implementation needs to allow for null EventType references.
1 parent dee6b52 commit 46246e9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/java/org/owasp/esapi/logging/appender/EventTypeLogSupplier.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public EventTypeLogSupplier(EventType evtyp) {
3939

4040
@Override
4141
public String get() {
42-
return eventType.toString();
42+
return eventType == null ? "" : eventType.toString();
4343
}
4444
}

src/test/java/org/owasp/esapi/logging/appender/EventTypeLogSupplierTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,12 @@ public void testEventTypeLog() {
1515

1616
assertEquals(eventType.toString(), supplier.get());
1717
}
18+
19+
@Test
20+
public void testNullEventTypeLog() {
21+
22+
EventTypeLogSupplier supplier = new EventTypeLogSupplier(null);
23+
24+
assertEquals("", supplier.get());
25+
}
1826
}

0 commit comments

Comments
 (0)