Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null not handled correctly for npe #25

Open
snaum opened this issue Oct 10, 2019 · 0 comments
Open

null not handled correctly for npe #25

snaum opened this issue Oct 10, 2019 · 0 comments

Comments

@snaum
Copy link

snaum commented Oct 10, 2019

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;
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant