Skip to content

Commit

Permalink
Destroy timer task when shutting down the bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jun 5, 2013
1 parent 6fa66de commit 8da0352
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion hawtio-git/src/main/java/io/hawt/git/GitFacade.java
Expand Up @@ -76,6 +76,7 @@ public class GitFacade extends MBeanSupport implements GitFacadeMXBean {
private boolean pullBeforeOperation = false;
private long pullTimePeriod;
private Timer timer;
private TimerTask task;
private PersonIdent stashPersonIdent;
private String defaultBranch;

Expand All @@ -100,7 +101,7 @@ public Object call() throws Exception {
return null;
}
};
TimerTask task = new TimerTask() {
task = new TimerTask() {
@Override
public void run() {
gitOperation(getStashPersonIdent(), emptyCallable);
Expand All @@ -111,6 +112,14 @@ public void run() {
super.init();
}

@Override
public void destroy() throws Exception {
if (task != null) {
task.cancel();
}
super.destroy();
}

public PersonIdent getStashPersonIdent() {
if (stashPersonIdent == null) {
stashPersonIdent = new PersonIdent("dummy", "dummy");
Expand Down

0 comments on commit 8da0352

Please sign in to comment.