Skip to content

Commit

Permalink
shutdown executors before connections
Browse files Browse the repository at this point in the history
Closes #5
  • Loading branch information
notnoop committed Nov 28, 2011
1 parent c0dc601 commit 9241aee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/com/notnoop/c2dm/internal/C2DMPooledService.java
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
package com.notnoop.c2dm.internal; package com.notnoop.c2dm.internal;


import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;


import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
Expand Down Expand Up @@ -71,8 +72,15 @@ public void run() {
@Override @Override
public void stop() { public void stop() {
super.stop(); super.stop();
this.httpClient.getConnectionManager().shutdown();
this.executor.shutdown(); this.executor.shutdown();
try {
if(!this.executor.awaitTermination(5, TimeUnit.SECONDS)) {
this.executor.shutdownNow();
}
} catch (InterruptedException e) {
}

this.httpClient.getConnectionManager().shutdown();
} }


} }

0 comments on commit 9241aee

Please sign in to comment.