Skip to content

Commit b7d9b87

Browse files
artembilangaryrussell
authored andcommitted
GH-3497: ReplyProducerCleaner: check only MPs
Fixes #3497 The `BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS` is filled up only with the `MessageProducer` instances. Therefore no reason to calculate a hash code for every single bean passed to the `ReplyProducerCleaner.requiresDestruction()` * Check for the `MessageProducer` instance before passing the bean to the `BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS.contains()` * Check for the `MessageProducer` in the `ReplyProducerCleaner.postProcessBeforeDestruction()`, too. It can be called independently of the `requiresDestruction()` and will calculate a hash code from the bean again for nothing **Cherry-pick to 5.4.x & 5.3.x**
1 parent a0fd683 commit b7d9b87

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

spring-integration-core/src/main/java/org/springframework/integration/dsl/BaseIntegrationFlowDefinition.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2020 the original author or authors.
2+
* Copyright 2019-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -3100,12 +3100,15 @@ private ReplyProducerCleaner() {
31003100

31013101
@Override
31023102
public boolean requiresDestruction(Object bean) {
3103-
return BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS.contains(bean);
3103+
return bean instanceof MessageProducer &&
3104+
BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS.contains(bean);
31043105
}
31053106

31063107
@Override
31073108
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
3108-
BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS.remove(bean);
3109+
if (bean instanceof MessageProducer) {
3110+
BaseIntegrationFlowDefinition.REFERENCED_REPLY_PRODUCERS.remove(bean);
3111+
}
31093112
}
31103113

31113114
}

0 commit comments

Comments
 (0)