由于使用aws s3上传、下载文件未关闭IO流,引发的血案
上传文件出现异常:
Unable to execute HTTP request: Timeout waiting for connection from pool
com.amazonaws.SdkClientException: Unable to execute HTTP request: Timeout waiting for connection from pool
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.handleRetryableException(AmazonHttpClient.java:1207)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeHelper(AmazonHttpClient.java:1153)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.doExecute(AmazonHttpClient.java:802)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.executeWithTimer(AmazonHttpClient.java:770)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.execute(AmazonHttpClient.java:744)
at com.amazonaws.http.AmazonHttpClient$RequestExecutor.access$500(AmazonHttpClient.java:704)
at com.amazonaws.http.AmazonHttpClient$RequestExecutionBuilderImpl.execute(AmazonHttpClient.java:686)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:550)
at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:530)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:5062)
at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:5008)
at com.amazonaws.services.s3.AmazonS3Client.access$300(AmazonS3Client.java:394)
at com.amazonaws.services.s3.AmazonS3Client$PutObjectStrategy.invokeServiceCall(AmazonS3Client.java:5950)
at com.amazonaws.services.s3.AmazonS3Client.uploadObject(AmazonS3Client.java:1812)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1772)
at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1710)
at jrx.anyservice.user.service.service.impl.UserImageInfoServiceImpl.uploadImg(UserImageInfoServiceImpl.java:295)
at jrx.anyservice.user.service.service.impl.UserImageInfoServiceImpl$$FastClassBySpringCGLIB$$2a48557.invoke(<generated>)
at org.springframework.cglib.proxy
当时以为是网络不好,然后设置更长的超时时间,但是还是没有用
查看服务器出现大量的close_wait状态的TCP连接,而且不会自动断开,一直占用着资源。查看代码原来是上传、下载的时候没有关闭IO流。