You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/10/23 11:18:16 UTC
[camel] branch main updated: (chores) camel-core: reduce method size to help inlining
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 18eab1f89d1 (chores) camel-core: reduce method size to help inlining
18eab1f89d1 is described below
commit 18eab1f89d12aa3f6c0cea4393f0ebd0eb2b51cc
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Mon Oct 23 12:19:34 2023 +0200
(chores) camel-core: reduce method size to help inlining
---
.../camel/impl/engine/CamelInternalProcessor.java | 14 ++++---
.../errorhandler/RedeliveryErrorHandler.java | 32 +++++++++------
.../java/org/apache/camel/support/EventHelper.java | 47 +++++++---------------
3 files changed, 44 insertions(+), 49 deletions(-)
diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
index e343e51536e..ce739a33819 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/CamelInternalProcessor.java
@@ -326,9 +326,9 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
if (exchange.isTransacted()) {
return processTransacted(exchange, afterTask);
- } else {
- return processNonTransacted(exchange, afterTask);
}
+
+ return processNonTransacted(exchange, afterTask);
}
private static boolean processShutdown(Exchange exchange, AsyncCallback originalCallback) {
@@ -364,13 +364,17 @@ public class CamelInternalProcessor extends DelegateAsyncProcessor implements In
// CAMEL-18255: move uow.afterProcess handling to the callback
if (LOG.isTraceEnabled()) {
- LOG.trace("Exchange processed and is continued routed {} for exchangeId: {} -> {}",
- sync ? "synchronously" : "asynchronously",
- exchange.getExchangeId(), exchange);
+ logExchangeContinuity(exchange, sync);
}
return sync;
}
+ private static void logExchangeContinuity(Exchange exchange, boolean sync) {
+ LOG.trace("Exchange processed and is continued routed {} for exchangeId: {} -> {}",
+ sync ? "synchronously" : "asynchronously",
+ exchange.getExchangeId(), exchange);
+ }
+
private AsyncCallback beforeProcess(Exchange exchange, CamelInternalTask afterTask) {
final UnitOfWork uow = exchange.getUnitOfWork();
diff --git a/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java b/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java
index f85d98e9481..60063459add 100644
--- a/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java
+++ b/core/camel-core-processor/src/main/java/org/apache/camel/processor/errorhandler/RedeliveryErrorHandler.java
@@ -430,22 +430,12 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport
return;
}
- // only new failure if the exchange has exception
- // and it has not been handled by the failure processor before
- // or not exhausted
- final boolean failure = exchange.getException() != null
- && !exchange.getExchangeExtension().isRedeliveryExhausted()
- && !ExchangeHelper.isFailureHandled(exchange);
- // error handled bridged
- final boolean bridge = ExchangeHelper.isErrorHandlerBridge(exchange);
-
- if (failure || bridge) {
+ if (isFailedOrBridged(exchange)) {
// previous processing cause an exception
handlePreviousFailure();
} else if (first) {
// first time call the target processor
- first = false;
- outputAsync.process(exchange, this);
+ handleFirst();
} else {
// we are done so continue callback
AsyncCallback cb = callback;
@@ -454,6 +444,24 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport
}
}
+ private static boolean isFailedOrBridged(Exchange exchange) {
+ // only new failure if the exchange has exception
+ // and it has not been handled by the failure processor before
+ // or not exhausted
+ final boolean failure = exchange.getException() != null
+ && !exchange.getExchangeExtension().isRedeliveryExhausted()
+ && !ExchangeHelper.isFailureHandled(exchange);
+ // error handled bridged
+ final boolean bridge = ExchangeHelper.isErrorHandlerBridge(exchange);
+
+ return failure || bridge;
+ }
+
+ private void handleFirst() {
+ first = false;
+ outputAsync.process(exchange, this);
+ }
+
private void handlePreviousFailure() {
handleException();
onExceptionOccurred();
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java
index 8fe24cf07bf..b9123e6e9e6 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/EventHelper.java
@@ -689,10 +689,7 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeCompletedEvent()) {
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeCompletedEvent()) {
continue;
}
@@ -735,10 +732,8 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
+
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeFailedEvents()) {
continue;
}
@@ -783,10 +778,8 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
+
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeFailedEvents()) {
continue;
}
@@ -831,10 +824,7 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeFailedEvents()) {
continue;
}
@@ -877,10 +867,8 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeFailedEvents()) {
+
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeFailedEvents()) {
continue;
}
@@ -923,10 +911,7 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeSendingEvents()) {
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeSendingEvents()) {
continue;
}
@@ -969,10 +954,7 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeSentEvents()) {
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeSentEvents()) {
continue;
}
@@ -1483,10 +1465,7 @@ public final class EventHelper {
// optimise for loop using index access to avoid creating iterator object
for (int i = 0; i < notifiers.size(); i++) {
EventNotifier notifier = notifiers.get(i);
- if (notifier.isDisabled()) {
- continue;
- }
- if (notifier.isIgnoreExchangeEvents() || notifier.isIgnoreExchangeAsyncProcessingStartedEvents()) {
+ if (isDisabledOrIgnored(notifier) || notifier.isIgnoreExchangeAsyncProcessingStartedEvents()) {
continue;
}
@@ -1503,6 +1482,10 @@ public final class EventHelper {
return answer;
}
+ private static boolean isDisabledOrIgnored(EventNotifier notifier) {
+ return notifier.isDisabled() || notifier.isIgnoreExchangeEvents();
+ }
+
private static boolean doNotifyEvent(EventNotifier notifier, CamelEvent event) {
if (!notifier.isEnabled(event)) {
LOG.trace("Notifier: {} is not enabled for the event: {}", notifier, event);