不再需要 @Async

This commit is contained in:
2026-06-08 17:36:49 +08:00
parent 29a87bf1c4
commit 10598a51cf
@@ -18,7 +18,6 @@ import java.net.InetAddress;
import java.net.Proxy;
import java.util.concurrent.TimeUnit;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.annotation.Async;
@Slf4j
public class GeoIPUtil {
@@ -35,7 +34,6 @@ public class GeoIPUtil {
}
}
@Async
public static IpInfo getIpInfoThroughProxy(ProxySetting proxySetting) {
if (proxySetting == null) {
throw new RuntimeException("代理为空");
@@ -66,7 +64,7 @@ public class GeoIPUtil {
String responseBody = response.body().string();
log.debug("Response ipv4 from proxy: {}", responseBody.trim());
ipInfo.setIp(responseBody);
} catch (IOException e) {
} catch (Exception e) {
log.warn("Proxy ipv4 error: {}", e.getMessage());
return IpInfo.EMPTY;
}
@@ -81,7 +79,7 @@ public class GeoIPUtil {
String responseBody = response.body().string();
log.debug("Response ipv6 from proxy: {}", responseBody.trim());
ipInfo.setIpv6(responseBody);
} catch (IOException e) {
} catch (Exception e) {
log.warn("Proxy ipv6 error {}", e.getMessage());
}
return queryIpInfoGeoLite(ipInfo);
@@ -104,7 +102,7 @@ public class GeoIPUtil {
if (response.getSubdivisions() != null && !response.getSubdivisions().isEmpty()) {
// 省
Subdivision subdivision = response.getSubdivisions().get(0);
Subdivision subdivision = response.getSubdivisions().getFirst();
if (subdivision != null) {
String subdivisionStr = subdivision.getNames().get(LOCALE);
ipInfo.setSubdivision(subdivisionStr);