[bugfix] fix wrong http user-agent content (#2996)

This commit is contained in:
tomsun28
2025-01-20 01:16:50 +08:00
committed by GitHub
parent 5441838888
commit fd7e1b0e05
2 changed files with 15 additions and 8 deletions
@@ -144,12 +144,25 @@ public class CommonHttpClient {
ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(1, threadFactory);
scheduledExecutor.scheduleWithFixedDelay(() -> {
connectionManager.closeExpiredConnections();
connectionManager.closeIdleConnections(100, TimeUnit.SECONDS);
connectionManager.closeIdleConnections(40, TimeUnit.SECONDS);
}, 40L, 40L, TimeUnit.SECONDS);
// shutdown hook
Runtime.getRuntime().addShutdownHook(new Thread(CommonHttpClient::close));
} catch (Exception ignored) {}
}
public static CloseableHttpClient getHttpClient() {
return httpClient;
}
public static void close() {
try {
httpClient.close();
} catch (Exception e) {
log.error("close http client error", e);
}
}
}