Skip to content

Commit b2cd8c3

Browse files
fix: correct conditional check for IP info search results (#694)
Updated the `getIpInfo` method to fix the conditional check when evaluating the total hits from the Elasticsearch search result. Changed the condition from `hits.total().value() < 0` to `hits.total().value() <= 0` to correctly handle cases where no search results are found, preventing potential `IndexOutOfBoundsException`.
1 parent a29bf78 commit b2cd8c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

backend/src/main/java/com/park/utmstack/service/ip_info/IpInfoService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public GeoIp getIpInfo(String ip) throws UtmIpInfoException {
4444

4545
HitsMetadata<GeoIp> hits = elasticsearchService.search(sr, GeoIp.class).hits();
4646

47-
if (hits.total().value() < 0)
47+
if (hits.total().value() <= 0)
4848
return null;
4949

5050
return hits.hits().get(0).source();

0 commit comments

Comments
 (0)