Mahoney / slf4j-test

Implementation of SLF4J which allows easy access to logging events in tests
39 stars 24 forks source link

null not handled correctly for npe #25

Open snaum opened 5 years ago

snaum commented 5 years ago

Null pointer exception is not getting handled correctly, because npe.getMessage() is itself null.

@Slf4j public class Demo { public static void doIt(){ Map<String, String> map = new ConcurrentHashMap<>(); try { map.put(null, null); } catch (NullPointerException npe) { log.error(npe.getMessage(), npe); } } }

class DemoTest extends Specification { def "DoIt"() { given: TestLogger logger = TestLoggerFactory.getTestLogger(Demo.class); Demo.doIt(); expect: logger.getAllLoggingEvents().size() > 0; } }