From 896c93024153db0f17fb517292ad41741e0ab1c7 Mon Sep 17 00:00:00 2001 From: ayushaga14 Date: Fri, 22 Nov 2024 14:50:35 +0530 Subject: [PATCH] throw excpetion if reader not initialised --- .../src/main/java/com/akto/utils/IpGeolocation.java | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/apps/api-threat-detection/src/main/java/com/akto/utils/IpGeolocation.java b/apps/api-threat-detection/src/main/java/com/akto/utils/IpGeolocation.java index e8ab9f179..e118fb15a 100644 --- a/apps/api-threat-detection/src/main/java/com/akto/utils/IpGeolocation.java +++ b/apps/api-threat-detection/src/main/java/com/akto/utils/IpGeolocation.java @@ -1,11 +1,7 @@ package com.akto.utils; -import java.io.BufferedReader; import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; import java.net.InetAddress; -import java.nio.file.Paths; import com.akto.log.LoggerMaker; import com.maxmind.geoip2.DatabaseReader; @@ -18,12 +14,8 @@ public class IpGeolocation { private static DatabaseReader reader; private static final LoggerMaker loggerMaker = new LoggerMaker(IpGeolocation.class); - public IpGeolocation() { - try { - reader = new DatabaseReader.Builder(database).build(); - } catch (Exception e) { - loggerMaker.errorAndAddToDb("IpGeolocation init failed " + e.getMessage()); - } + public IpGeolocation() throws Exception { + reader = new DatabaseReader.Builder(database).build(); } public String fetchLocationByIp(String ip) throws Exception {