How to handle AWS connection reaper Error


SEVERE: The web application [] appears to have started a thread named [java-sdk-http-connection-reaper] but has failed to stop it. This is very likely to create a memory leak.”

Root cause

This issue is caused by AWS Java SDK Client library which starts a thread in the background called com.amazonaws.http.IdleConnectionReaper.


Ideally, AWS should provide some cleaner to handle this error. Workaround is to call shutdown method yourslef in the code. Below example provides solution for Spring based applications using Java Config. High level, you have to do 2 things:

  1. Declare a bean.
  2. Add @Predestroy method in that bean which can invoke shutdown method explicitly.
  // Create a bean to register destroy method where we can shutdown the 
  //  httpconnection objects left open by AWS SDK
  // @return AmazonDynamoDBClient
  public AwsIdleConnectionShutdownBean awsIdleConnectionShutdownBean() {
      return new AwsIdleConnectionShutdownBean();
public class AwsIdleConnectionShutdownBean {

  private static final Logger LOGGER = LoggerFactory
  private void cleanUp() {
      try {
          // Shutting down AWS IdleConnectionReaper thread...
"Shutting down AWS IdleConnectionReaper thread ");
      } catch (Throwable t) {
          // log error
          LOGGER.error("Shutting down AWS IdleConnectionReaper thread failed.");



# Reference

Version History

Date Description
2016-06-26    Initial Version