Details
-
Bug
-
Resolution: Duplicate
-
Major - P3
-
None
-
3.12.2
-
None
-
None
-
Java 11
Description
Description
The constructor of com.mongodb.client.model.geojson.PolygonCoordinates throws a NullPointerException when it is invoked with a List created by the factory method java.util.List.of().
Example
var polygonCoordinates = new PolygonCoordinates(List.of( |
new Position(-122.4547, 37.77475), |
new Position(-122.45302, 37.76638), |
new Position(-122.51033, 37.76398), |
new Position(-122.511, 37.77133), |
new Position(-122.4547, 37.77475) |
));
|
Explanation
The factory method java.util.List.of() creates an instance of AbstractImmutableList. And the constructor of PolygonCoordinates checks if, e.g., its argument exterior contains a null value by invoking exterior.contains(null). But the method call AbstractImmutableList.contains(null) throws a NullPointerException.
Suggestion
Replace list.contains(null) with:
list.stream().anyMatch(Objects::isNull);
|
Attachments
Issue Links
- duplicates
-
JAVA-3635 GeoJSON Geometry constructors throw NPE
-
- Closed
-