Skip to content

Commit d620ff9

Browse files
committed
Fix Checkstyle violations & typos in StreamBridge
Remove also a duplicated code from the `setAsync()` which, essentially, may lead to the problem with class loader when `context-propagation` is optional on classpath
1 parent 7fa7228 commit d620ff9

File tree

1 file changed

+6
-8
lines changed
  • core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function

1 file changed

+6
-8
lines changed

core/spring-cloud-stream/src/main/java/org/springframework/cloud/stream/function/StreamBridge.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@
7171
/**
7272
* A class which allows user to send data to an output binding.
7373
* While in a common scenario of a typical spring-cloud-stream application user rarely
74-
* has to manually send data, there are times when the sources of data are outside of
75-
* spring-cloud-stream context and therefore we need to bridge such foreign sources
74+
* has to manually send data, there are times when the sources of data are outside
75+
* spring-cloud-stream context, and therefore we need to bridge such foreign sources
7676
* with spring-cloud-stream.
7777
* <br><br>
7878
* This utility class allows user to do just that - <i>bridge non-spring-cloud-stream applications
7979
* with spring-cloud-stream</i> by providing a mechanism (bridge) to send data to an output binding while
80-
* maintaining the same invocation contract (i.e., type conversion, partitioning etc) as if it was
80+
* maintaining the same invocation contract (i.e., type conversion, partitioning etc.) as if it was
8181
* done through a declared function.
8282
*
8383
* @author Oleg Zhurakousky
@@ -114,7 +114,7 @@ public final class StreamBridge implements StreamOperations, SmartInitializingSi
114114
private final FunctionInvocationHelper<?> functionInvocationHelper;
115115

116116
private ExecutorService executorService;
117-
117+
118118
private static final boolean isContextPropagationPresent = ClassUtils.isPresent(
119119
"io.micrometer.context.ContextSnapshotFactory", StreamBridge.class.getClassLoader());
120120

@@ -334,7 +334,7 @@ public void destroy() throws Exception {
334334
else {
335335
this.executorService.shutdown();
336336
}
337-
337+
338338
this.executorService = null;
339339
this.async = false;
340340
channelCache.keySet().forEach(bindingService::unbindProducers);
@@ -349,11 +349,9 @@ public void setAsync(boolean async) {
349349
if (isContextPropagationPresent) {
350350
this.executorService = ContextPropagationHelper.wrap(this.executorService);
351351
}
352-
this.executorService = ContextExecutorService
353-
.wrap(Executors.newCachedThreadPool(), () -> ContextSnapshotFactory.builder().build().captureAll());
354352
this.async = async;
355353
}
356-
354+
357355
private static final class ContextPropagationHelper {
358356
static ExecutorService wrap(ExecutorService executorService) {
359357
return ContextExecutorService.wrap(executorService, () -> ContextSnapshotFactory.builder().build().captureAll());

0 commit comments

Comments
 (0)