GGraziadei commented on code in PR #9159:
URL: https://github.com/apache/storm/pull/9159#discussion_r4250730683


##########
storm-client/src/jvm/org/apache/storm/messaging/netty/StormServerHandler.java:
##########
@@ -59,12 +61,20 @@ public void exceptionCaught(ChannelHandlerContext ctx, 
Throwable cause) {
             // Doing nothing (probably due to an oom issue) and hoping 
Utils.handleUncaughtException will handle it
         }
         try {
-            Utils.handleUncaughtException(cause, ALLOWED_EXCEPTIONS, false);
+            Utils.handleUncaughtException(cause, allowedExceptions(cause), 
false);
             ctx.close();
         } catch (Error error) {
             LOG.info("Received error in netty thread.. terminating server...");
             Runtime.getRuntime().exit(1);
         }
 
     }
+
+    // A strict-mode deserialization failure must terminate the worker even if 
it wraps an IOException.
+    static Set<Class<?>> allowedExceptions(Throwable cause) {

Review Comment:
   Note: Discovered using an LLM scan Opus 5.5
   
   Non-blocking: this helper returns an empty set only so that 
`Utils.handleUncaughtException` throws an `Error`, which the `catch (Error)` 
above then turns into an exit. The fatal decision ends up spread across three 
places (this helper, the allowed-set loop in `Utils`, and the catch block), and 
`FatalDeserializationException` is always the top-level throwable coming out of 
`recv`, so the cause-chain walk is not needed either. A direct check at the top 
of `exceptionCaught` would express the intent in one spot:
   
   ```java
   if (cause instanceof FatalDeserializationException) {
       LOG.error("Strict deserialization failure, terminating worker", cause);
       Runtime.getRuntime().exit(1);
       return;
   }
   ```



##########
storm-client/src/jvm/org/apache/storm/messaging/netty/StormServerHandler.java:
##########
@@ -59,12 +61,20 @@ public void exceptionCaught(ChannelHandlerContext ctx, 
Throwable cause) {
             // Doing nothing (probably due to an oom issue) and hoping 
Utils.handleUncaughtException will handle it
         }
         try {
-            Utils.handleUncaughtException(cause, ALLOWED_EXCEPTIONS, false);
+            Utils.handleUncaughtException(cause, allowedExceptions(cause), 
false);
             ctx.close();
         } catch (Error error) {
             LOG.info("Received error in netty thread.. terminating server...");

Review Comment:
   With this PR the common strict-mode case now routes through this `exit(1)` 
on the netty I/O thread. The worker shutdown hook then calls `mqContext.term()` 
thus `Server.close()` thus 
`workerEventLoopGroup.shutdownGracefully().awaitUninterruptibly()`, which can 
never complete because the event-loop thread is parked inside `exit()`. 
   This path existed before for non-IO failures, but now it is the documented 
behaviour for strict mode, so it is worth making it clean: either 
`Runtime.getRuntime().halt(1)` here, or hand the `exit(1)` to a separate thread 
so the netty loop can be shut down. Fine as a follow-up if you prefer.
   Note: I discevered this with static instepction Claude Opus confirmed. 



##########
storm-client/test/jvm/org/apache/storm/messaging/netty/StormServerHandlerTest.java:
##########
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The 
ASF licenses this file to you under the Apache License, Version
+ * 2.0 (the "License"); you may not use this file except in compliance with 
the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions
+ * and limitations under the License.
+ */
+
+package org.apache.storm.messaging.netty;
+
+import java.io.IOException;
+import org.apache.storm.messaging.FatalDeserializationException;
+import org.apache.storm.utils.Utils;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+public class StormServerHandlerTest {
+
+    @Test
+    public void testIoExceptionIsSwallowed() {

Review Comment:
   Both tests here call `Utils.handleUncaughtException` with the output of 
`allowedExceptions`, so they cover the helper and `Utils`, but not 
`exceptionCaught` itself, which is the method whose behaviour the PR changes. 
If the fatal check moves into `exceptionCaught `, these tests would no longer 
cover it at all.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to