From 88705f363b6bd4f429aad3fb0617f9e04259bdf7 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Tue, 23 Apr 2024 01:36:33 -0400 Subject: [PATCH] Fix MaxMind NPE --- .../java/cc/restfulmc/api/service/MaxMindService.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/API/src/main/java/cc/restfulmc/api/service/MaxMindService.java b/API/src/main/java/cc/restfulmc/api/service/MaxMindService.java index 2de722c..98a0aea 100644 --- a/API/src/main/java/cc/restfulmc/api/service/MaxMindService.java +++ b/API/src/main/java/cc/restfulmc/api/service/MaxMindService.java @@ -108,11 +108,12 @@ public final class MaxMindService { * Lookup a city by the given address. * * @param address the address - * @return the city response + * @return the city response, null if none */ - @SneakyThrows @NonNull + @SneakyThrows public CityResponse lookupCity(@NonNull InetAddress address) { - return getDatabase(Database.CITY).city(address); + DatabaseReader database = getDatabase(Database.CITY); + return database == null ? null : database.city(address); } /** @@ -181,9 +182,8 @@ public final class MaxMindService { * Get the reader for the given database. * * @param database the database to get - * @return the database reader + * @return the database reader, null if none */ - @NonNull public DatabaseReader getDatabase(@NonNull Database database) { return databases.get(database); }