diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java index bcb4c3e79e..f02e6c0ef6 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonMultiPoint.java @@ -79,7 +79,7 @@ public GeoJsonMultiPoint(Point first, Point second, Point... others) { Assert.notNull(second, "Second point must not be null"); Assert.notNull(others, "Additional points must not be null"); - this.points = new ArrayList<>(); + this.points = new ArrayList<>(2 + others.length); this.points.add(first); this.points.add(second); this.points.addAll(Arrays.asList(others)); diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonPolygon.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonPolygon.java index 166a10df08..3d828595f9 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonPolygon.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/geo/GeoJsonPolygon.java @@ -126,7 +126,13 @@ public List getCoordinates() { private static List asList(Point first, Point second, Point third, Point fourth, Point... others) { - ArrayList result = new ArrayList(3 + others.length); + Assert.notNull(first, "First point must not be null"); + Assert.notNull(second, "Second point must not be null"); + Assert.notNull(third, "Third point must not be null"); + Assert.notNull(fourth, "Fourth point must not be null"); + Assert.notNull(others, "Additional points must not be null"); + + ArrayList result = new ArrayList(4 + others.length); result.add(first); result.add(second);