gnodet opened a new pull request, #21209: URL: https://github.com/apache/camel/pull/21209
## Description Fixes memory leak in Google PubSub consumer when subscription doesn't exist. ## Problem When a subscription no longer exists, starting a subscriber throws a `NotFoundException`. However, the subscriber was being added to the `subscribers` list BEFORE the `startAsync().awaitRunning()` call. This caused subscribers to accumulate in the list on repeated failures, leading to unbounded memory growth until JVM runs out of memory. Additionally, there was no backoff delay, causing a tight loop that consumed CPU resources. ## Solution This fix addresses the issue in both `GooglePubsubConsumer` and `GooglePubsubLiteConsumer`: 1. **Reordered subscriber list management**: Subscribers are now added to the list AFTER successful startup 2. **Added proper cleanup**: Subscribers are removed from the list in the catch block if startup fails 3. **Added backoff delay**: 5-second delay on failures to prevent tight loop 4. **Ensured cleanup in finally block**: Subscribers are removed from the list to prevent leaks ## Testing - ✅ Compiled both components successfully - ✅ All existing tests pass (camel-google-pubsub: 4 tests, camel-google-pubsub-lite: 6 tests) - ✅ No breaking changes to existing functionality ## Related Issue https://issues.apache.org/jira/browse/CAMEL-22898 --- Pull Request opened by [Augment Code](https://www.augmentcode.com/) with guidance from the PR author -- 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]
