Steve973 commented on code in PR #11906:
URL: https://github.com/apache/camel/pull/11906#discussion_r1383883485


##########
components/camel-dynamic-router/src/main/java/org/apache/camel/component/dynamicrouter/DynamicRouterControlChannelProcessor.java:
##########
@@ -156,20 +157,22 @@ DynamicRouterControlMessage handleControlMessage(final 
Exchange exchange) {
     public boolean process(final Exchange exchange, final AsyncCallback 
callback) {
         LOG.debug("Received control channel message");
         DynamicRouterControlMessage controlMessage = 
handleControlMessage(exchange);
-        final DynamicRouterProcessor processor = 
Optional.ofNullable(component.getRoutingProcessor(controlMessage.getChannel()))
-                .orElseThrow(() -> new IllegalArgumentException(
-                        "Control channel message is invalid: wrong channel, or 
no processors present."));
-        switch (controlMessage.getMessageType()) {
-            case SUBSCRIBE:
-                processor.addFilter(controlMessage);
-                exchange.getIn().setBody(controlMessage.getId(), String.class);
-                break;
-            case UNSUBSCRIBE:
-                processor.removeFilter(controlMessage.getId());
-                break;
-            default:
-                // Cannot get here due to enum
-                break;
+        try (DynamicRouterMulticastProcessor processor
+                = 
Optional.ofNullable(component.getRoutingProcessor(controlMessage.getChannel()))
+                        .orElseThrow(() -> new IllegalArgumentException(
+                                "Control channel message is invalid: wrong 
channel, or no processors present."))) {
+            switch (controlMessage.getMessageType()) {
+                case SUBSCRIBE -> {
+                    processor.addFilter(controlMessage);
+                    exchange.getIn().setBody(controlMessage.getId(), 
String.class);
+                }
+                case UNSUBSCRIBE -> 
processor.removeFilter(controlMessage.getId());
+                default -> {
+                    // Cannot get here due to enum
+                }
+            }
+        } catch (IOException e) {
+            throw new RuntimeException(e);

Review Comment:
   Thanks.  I'll change it as requested.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to