我们有一个使用AWS(Amazone api)的Web应用程序,在coreConfiguration类中我们使用predestroy方法创建一个awsApi bean,coreConfiguration的代码是:
@Bean(destroyMethod = "destroy")
public IGridStorageManager awsApi() {
.....
}
Run Code Online (Sandbox Code Playgroud)
在 awsApi 类中我们有 detroy 方法,代码是:
@Override
@PreDestroy
public void destroy() {
if (clientS3 != null) {
clientS3.shutdown();
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是在 PROD 中的某个时候,当我使用 API 时,我看到了这些日志:
2020-08-03 11:27:00.090 DEBUG 25172 --- [java-sdk-http-connection-reaper] com.amazonaws.http.IdleConnectionReaper : Reaper thread:
java.lang.InterruptedException: sleep interrupted
at java.lang.Thread.sleep(Native Method)
at com.amazonaws.http.IdleConnectionReaper.run(IdleConnectionReaper.java:188)
Run Code Online (Sandbox Code Playgroud)
我读到这个异常可能导致内存泄漏,我发现我们需要使用 shutdown() 方法,问题是我已经将@PreDestroy方法与 shutdown 方法一起使用,为什么我有这些异常?
你能帮助我吗 ?
谢谢