Skip to content

[Bug] Silent reconnection failure in SmppSessionFactoryBean due to swallowed exceptions in submit() #264

@QiuYucheng2003

Description

@QiuYucheng2003

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

  1. The exception is captured by the Future returned by submit().

  2. Since the code ignores the returned Future (never calls get()), the exception is effectively swallowed.

  3. 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);
}
}
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions