gnodet commented on code in PR #25333:
URL: https://github.com/apache/camel/pull/25333#discussion_r3718148416
##########
components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/InOutQueueProducerAsyncLoadTest.java:
##########
@@ -70,43 +74,42 @@ public void cleanupConsumers() throws JMSException {
/**
* Test to verify that when using the consumer listener for the InOut
producer we get the correct message back.
- *
- * @throws Exception
*/
@Test
- public void testInOutQueueProducer() throws Exception {
- final int messageCount = 500;
- final CountDownLatch latch = new CountDownLatch(messageCount);
+ void testInOutQueueProducer() throws Exception {
+ final CountDownLatch latch = new CountDownLatch(MESSAGE_COUNT);
final AtomicInteger failures = new AtomicInteger();
ExecutorService executor = Executors.newFixedThreadPool(2);
-
- for (int i = 1; i <= messageCount; i++) {
- final int tempI = i;
- executor.execute(() -> {
- try {
- final String requestText = "Message " + tempI;
- final String responseText = "Response Message " + tempI;
- String response = template.requestBody("direct:start",
requestText, String.class);
- assertNotNull(response);
- assertEquals(responseText, response);
- } catch (Exception e) {
- failures.incrementAndGet();
- log.error("Failed to process message {}", tempI, e);
- } finally {
- latch.countDown();
- }
- });
+ try {
+ for (int i = 1; i <= MESSAGE_COUNT; i++) {
+ final int tempI = i;
+ executor.execute(() -> {
+ try {
+ final String requestText = "Message " + tempI;
+ final String responseText = "Response Message " +
tempI;
+ String response = template.requestBody("direct:start",
requestText, String.class);
+ assertNotNull(response);
+ assertEquals(responseText, response);
+ } catch (Throwable e) {
Review Comment:
**[Low — style]** `catch (Throwable e)` is slightly broader than necessary.
Since the intent is to catch both `Exception` (from `requestBody`) and
`AssertionError` (from `assertNotNull`/`assertEquals`), using a multi-catch
would be more precise:
```suggestion
} catch (Exception | AssertionError e) {
```
Functionally equivalent here since the error is tracked via `failures`, so
not blocking — just a minor precision improvement.
--
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]