Open snaum opened 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; } }
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; } }