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

Improve ErrorMassage on null-object in MapReducer #159

Closed
SlowMo24 opened this issue Apr 12, 2019 · 2 comments · Fixed by #160
Closed

Improve ErrorMassage on null-object in MapReducer #159

SlowMo24 opened this issue Apr 12, 2019 · 2 comments · Fixed by #160
Assignees
Labels
user experience Enhances the usability of OSHDB

Comments

@SlowMo24
Copy link
Contributor

Problem
A hard to decipher NullPointerException is thrown if the return-element of the map-step of a MapReducer is null and .uniq() is called.

Favorite solution
null-objects should simply be possible as a result, also for uniq().

Alternatives
The error-message should be improved and the javadoc of map as well as uniq should be updated, to inform users to not generate null-values.

@SlowMo24 SlowMo24 added the user experience Enhances the usability of OSHDB label Apr 12, 2019
@tyrasd
Copy link
Member

tyrasd commented Apr 12, 2019

do you have a few lines of code at hand that trigger the null pointer exception?

//edit: ah, got it. Anything like this triggers it:

        …
        .map(x -> null)
        .uniq();

//edit2: the null pointer exception is thrown here:

https://github.com/GIScience/oshdb/blob/51718d5/oshdb-api/src/main/java/org/heigit/bigspatialdata/oshdb/api/mapreducer/MapReducer.java#L1931

@tyrasd
Copy link
Member

tyrasd commented Apr 12, 2019

a slightly off topic, but related general advice: please try to simply avoid using the null construct (not only) in java. If you need a special "thing" to represent "missing data" (or something similar), consider the null object pattern instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
user experience Enhances the usability of OSHDB
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants