davsclaus commented on code in PR #29677:
URL: https://github.com/apache/camel/pull/29677#discussion_r4556632646


##########
components/camel-smpp/src/test/java/org/apache/camel/component/smpp/MessageReceiverListenerImplTest.java:
##########
@@ -166,4 +167,33 @@ public void configure() {
             trxContext.stop();
         }
     }
+
+    @Test
+    void aMessageArrivingBeforeInitializationIsRejected() throws Exception {
+        DefaultCamelContext trxContext = new DefaultCamelContext();
+        trxContext.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() {
+                
from("direct:messageReceiver").routeId("messageReceiver").process(e -> {
+                });
+            }
+        });
+        when(endpoint.getCamelContext()).thenReturn(trxContext);
+
+        // the context is never started, so the StartupListener never runs and 
consumer/processor stay null
+        MessageReceiverListenerImpl listener = new 
MessageReceiverListenerImpl(endpoint, "messageReceiver");
+
+        try {
+            // makes the bounded wait return at once instead of taking its 
full timeout
+            Thread.currentThread().interrupt();
+
+            ProcessRequestException e
+                    = assertThrows(ProcessRequestException.class, () -> 
listener.onAcceptDeliverSm(deliverSm()));
+            assertTrue(e.getMessage().contains("not initialized"), 
e.getMessage());
+            assertTrue(Thread.currentThread().isInterrupted(), "the interrupt 
flag has to be restored");
+        } finally {
+            // clear the flag so it cannot leak into another test on this 
thread

Review Comment:
   Not blocking: `onAcceptDataSm` goes through the same `awaitInitialization()` 
guard as `onAcceptDeliverSm`, which the new test covers. A parallel assertion 
would be nice to have, not required for this fix.
   
   _Claude Code on behalf of davsclaus_



-- 
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