[Bug] Silent reconnection failure in SmppSessionFactoryBean due to swallowed exceptions in submit()
In SmppSessionFactoryBean.java, the scheduleReconnect() method submits a reconnection task to reconnectingExecutor using submit().
The Defect (ENC - Exception Not Caught): The submitted Runnable (lines ~310) contains a try-catch block that only catches InterruptedException. Crucially, if the connect() method or any logic inside the run() method throws a RuntimeException (e.g., NullPointerException, IllegalArgumentException):
-
The exception is captured by the Future returned by submit().
-
Since the code ignores the returned Future (never calls get()), the exception is effectively swallowed.
-
The reconnection thread terminates silently without any error logs.
Impact: If an unexpected error occurs during reconnection, the auto-reconnect mechanism stops working permanently, and no logs are produced to indicate why.
Code Analysis Location: org.springframework.integration.smpp.session.SmppSessionFactoryBean#scheduleReconnect // Current Implementation reconnectingExecutor.submit(new Runnable() { @Override public void run() { try { // ... logic ... connect(); // If this throws RuntimeException... } catch (InterruptedException e) { // ... handles interruption ... } // MISSING: catch (Throwable t) to handle unexpected runtime exceptions } }); // Future is discarded here, so exceptions are lost.
Expected Behavior The reconnection task should be robust. Any unexpected exception during the connection attempt should be caught and logged with ERROR level to prevent silent thread death.
Suggested Fix Add a catch-all block inside the Runnable to ensure exceptions are logged. reconnectingExecutor.submit(new Runnable() { @Override public void run() { try { Thread.sleep(reconnectInterval); // ... existing logic ... connect(); // ... existing logic ... } catch (InterruptedException e) { log.info("Interrupted..."); } catch (Throwable t) { // FIX: Log unexpected errors to prevent silent failure log.error("Unexpected error during SMPP reconnection", t); } } });
@QiuYucheng2003 , Since this report is fully similar to other by you, I won’t repeat myself , but just point to my comment over there: https://github.com/spring-projects/spring-integration/issues/10696#issuecomment-3738233270 Thanks