Skip to content

Commit 98ea34c

Browse files
committed
Use the new-in-Java-19 pre-sized HashMap utility
On Elasticsearch 9.0 and above, the minimum JVM version is 21, so we can use new-fangled functions like this.
1 parent d6e9c7c commit 98ea34c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/MaxmindIpDataLookups.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ protected Map<String, Object> transform(final CityResponse response) {
266266
Double latitude = location.getLatitude();
267267
Double longitude = location.getLongitude();
268268
if (latitude != null && longitude != null) {
269-
Map<String, Object> locationObject = new HashMap<>();
269+
Map<String, Object> locationObject = HashMap.newHashMap(2);
270270
locationObject.put("lat", latitude);
271271
locationObject.put("lon", longitude);
272272
data.put("location", locationObject);
@@ -539,7 +539,7 @@ protected Map<String, Object> transform(final EnterpriseResponse response) {
539539
Double latitude = location.getLatitude();
540540
Double longitude = location.getLongitude();
541541
if (latitude != null && longitude != null) {
542-
Map<String, Object> locationObject = new HashMap<>();
542+
Map<String, Object> locationObject = HashMap.newHashMap(2);
543543
locationObject.put("lat", latitude);
544544
locationObject.put("lon", longitude);
545545
data.put("location", locationObject);

0 commit comments

Comments
 (0)