diff --git a/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java b/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java index 04da278728..2b6cac08d0 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/IntegrationMessageHeaderAccessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java index 28567482d5..919525c454 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/DefaultHeaderChannelRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright 2013-2014 the original author or authors. + * Copyright 2013-2015 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -236,17 +236,15 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport * Cancel the scheduled reap task and run immediately; then reschedule. */ @Override - public void runReaper() { - synchronized(this) { - this.reaperScheduledFuture.cancel(false); - this.reaperScheduledFuture = null; + public synchronized void runReaper() { + if (this.reaperScheduledFuture != null) { + this.reaperScheduledFuture.cancel(true); } this.run(); } @Override - public void run() { - this.reaperScheduledFuture = null; + public synchronized void run() { if (logger.isTraceEnabled()) { logger.trace("Reaper started; channels size=" + this.channels.size()); } @@ -261,12 +259,8 @@ public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport iterator.remove(); } } - synchronized (this) { - if (this.reaperScheduledFuture == null) { - this.reaperScheduledFuture = this.getTaskScheduler().schedule(this, - new Date(System.currentTimeMillis() + this.reaperDelay)); - } - } + this.reaperScheduledFuture = this.getTaskScheduler().schedule(this, + new Date(System.currentTimeMillis() + this.reaperDelay)); if (logger.isTraceEnabled()) { logger.trace("Reaper completed; channels size=" + this.channels.size()); }