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

Fix NullPointerException if exception is in the default package #79

Closed

Conversation

mikej
Copy link

@mikej mikej commented Sep 9, 2013

getPackage() returns null if the class is in the default package so
getPackage().getName() would result in a NullPointerException in
this scenario.

I discovered this when writing some example code for investigating an unrelated issue with Sentry.
It's a bit of an edge case but seems worth adding a fix for it.

getPackage() returns null if the class is in the default package so
getPackage().getName() would result in a NullPointerException in
this scenario.
@ColinHebert
Copy link

I wonder if it wouldn't be better to provide a default value when the package name isn't available, ie (default).

@ColinHebert
Copy link

I took the liberty to modify your commit to include the (default) name and add a unit test.

Fixed in @51618d6e0149644b456a5c9df3e3575a035f5d9b

@ColinHebert ColinHebert closed this Sep 9, 2013
@mikej
Copy link
Author

mikej commented Sep 10, 2013

Thanks for the improvements. Having a default value definitely makes sense, and I really like the way you've done the unit test. I was looking for an elegant way to do that.

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

Successfully merging this pull request may close these issues.

2 participants