mayurbm opened a new pull request, #25907: URL: https://github.com/apache/camel/pull/25907
## Summary Fixes [CAMEL-24567](https://issues.apache.org/jira/browse/CAMEL-24567). One-line defensive fix in `MailConsumer.poll()`. ## The bug In the `finally` block, `folder.close(true)` is guarded by `if (folder != null && folder.isOpen())`, but the `catch` block logs `folder.getName()` **without** a null check: ```java if (folder != null && folder.isOpen()) { folder.close(true); } catch (Exception e) { // CAMEL-1263 LOG.debug("Could not close mailbox folder: {}. This exception is ignored.", folder.getName(), e); // ^^^^^^^^^^^^^^^^ NPE if null } ``` If `folder.close()` throws **and** a concurrent `disconnect()` has nulled the `folder` field between the `if`-guard and the catch body, the `LOG.debug` call throws `NullPointerException`. ## Fix ```java LOG.debug("Could not close mailbox folder: {}. This exception is ignored.", folder != null ? folder.getName() : "null", e); ``` ## Test `MailConsumerFolderNullCatchTest` — uses Mockito + reflection to simulate `folder.close()` throwing and setting `folder = null` concurrently, then verifies `poll()` does not throw NPE. ## Test Results ``` Tests run: 1, Failures: 0 [JDK 21] Full camel-mail suite: BUILD SUCCESS ``` ## AI Attribution _Claude Code on behalf of mayurbm_ ``` Co-authored-by: Claude Sonnet 4.5 <[email protected]> ``` -- 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]
