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 2024/01/05 08:45:00 UTC

(camel) branch main updated (7562084590c -> 78a54ac527c)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 7562084590c (chores) Ensures logging consistency for the UnitOfWorkHelper
     new 34e8cf70a3f (chores) camel-core: removed unused method from the AbstractCamelContext
     new 5d7727fe49f (chores) camel-core: removed unused exceptions from the AbstractCamelContext
     new 8808d45f552 (chores) camel-core: cleanup overly verbose comment
     new 78a54ac527c (chores) camel-core: break large methods

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/impl/engine/AbstractCamelContext.java    | 147 +++++++++------------
 1 file changed, 63 insertions(+), 84 deletions(-)


(camel) 03/04: (chores) camel-core: cleanup overly verbose comment

Posted by or...@apache.org.
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

commit 8808d45f552b22277f1d395395bb2851e967ee8b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jan 4 16:19:01 2024 +0100

    (chores) camel-core: cleanup overly verbose comment
---
 .../camel/impl/engine/AbstractCamelContext.java     | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 38c10922010..100f1b58471 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -546,27 +546,6 @@ public abstract class AbstractCamelContext extends BaseService
                 // creates the bean and then check the type so the getComponent
                 // is always triggered.
                 //
-                // Simple circular dependency:
-                //
-                // <camelContext id="camel"
-                // xmlns="http://camel.apache.org/schema/spring">
-                // <route>
-                // <from id="twitter"
-                // uri="twitter://timeline/home?type=polling"/>
-                // <log message="Got ${body}"/>
-                // </route>
-                // </camelContext>
-                //
-                // Complex circular dependency:
-                //
-                // <camelContext id="camel"
-                // xmlns="http://camel.apache.org/schema/spring">
-                // <route>
-                // <from id="log" uri="seda:test"/>
-                // <to id="seda" uri="log:test"/>
-                // </route>
-                // </camelContext>
-                //
                 // This would freeze the app (lock or infinite loop).
                 //
                 // See https://issues.apache.org/jira/browse/CAMEL-11225


(camel) 01/04: (chores) camel-core: removed unused method from the AbstractCamelContext

Posted by or...@apache.org.
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

commit 34e8cf70a3f63445987b7dd7a8bb3b408bb41ad2
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jan 4 16:12:53 2024 +0100

    (chores) camel-core: removed unused method from the AbstractCamelContext
---
 .../org/apache/camel/impl/engine/AbstractCamelContext.java     | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 7081ec8cb80..7561d8af92b 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -381,16 +381,6 @@ public abstract class AbstractCamelContext extends BaseService
         }
     }
 
-    /**
-     * Reset context counter to a preset value. Mostly used for tests to ensure a predictable getName()
-     *
-     * @param value new value for the context counter
-     */
-    public static void setContextCounter(int value) {
-        DefaultCamelContextNameStrategy.setCounter(value);
-        DefaultManagementNameStrategy.setCounter(value);
-    }
-
     public void close() throws IOException {
         try {
             stop();


(camel) 04/04: (chores) camel-core: break large methods

Posted by or...@apache.org.
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

commit 78a54ac527c755de82ab2b46f22c348dbbd7dd9b
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jan 4 16:58:54 2024 +0100

    (chores) camel-core: break large methods
---
 .../camel/impl/engine/AbstractCamelContext.java    | 102 +++++++++++----------
 1 file changed, 56 insertions(+), 46 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 100f1b58471..c1aed60c68a 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -676,7 +676,7 @@ public abstract class AbstractCamelContext extends BaseService
             answer.add(oldEndpoint);
             stopServices(oldEndpoint);
         } else {
-            String decodeUri = URISupport.getDecodeQuery(uri);
+            final String decodeUri = URISupport.getDecodeQuery(uri);
             if (decodeUri != null) {
                 oldEndpoint = endpoints.remove(getEndpointKey(decodeUri));
             }
@@ -684,22 +684,7 @@ public abstract class AbstractCamelContext extends BaseService
                 answer.add(oldEndpoint);
                 stopServices(oldEndpoint);
             } else {
-                List<NormalizedUri> toRemove = new ArrayList<>();
-                for (Map.Entry<NormalizedUri, Endpoint> entry : endpoints.entrySet()) {
-                    oldEndpoint = entry.getValue();
-                    if (EndpointHelper.matchEndpoint(this, oldEndpoint.getEndpointUri(), uri)) {
-                        try {
-                            stopServices(oldEndpoint);
-                        } catch (Exception e) {
-                            LOG.warn("Error stopping endpoint {}. This exception will be ignored.", oldEndpoint, e);
-                        }
-                        answer.add(oldEndpoint);
-                        toRemove.add(entry.getKey());
-                    }
-                }
-                for (NormalizedUri key : toRemove) {
-                    endpoints.remove(key);
-                }
+                tryMatchingEndpoints(uri, answer);
             }
         }
 
@@ -713,6 +698,26 @@ public abstract class AbstractCamelContext extends BaseService
         return answer;
     }
 
+    private void tryMatchingEndpoints(String uri, Collection<Endpoint> answer) {
+        Endpoint oldEndpoint;
+        List<NormalizedUri> toRemove = new ArrayList<>();
+        for (Map.Entry<NormalizedUri, Endpoint> entry : endpoints.entrySet()) {
+            oldEndpoint = entry.getValue();
+            if (EndpointHelper.matchEndpoint(this, oldEndpoint.getEndpointUri(), uri)) {
+                try {
+                    stopServices(oldEndpoint);
+                } catch (Exception e) {
+                    LOG.warn("Error stopping endpoint {}. This exception will be ignored.", oldEndpoint, e);
+                }
+                answer.add(oldEndpoint);
+                toRemove.add(entry.getKey());
+            }
+        }
+        for (NormalizedUri key : toRemove) {
+            endpoints.remove(key);
+        }
+    }
+
     @Override
     public Endpoint getEndpoint(String uri) {
         final StartupStepRecorder startupStepRecorder = camelContextExtension.getStartupStepRecorder();
@@ -1216,35 +1221,7 @@ public abstract class AbstractCamelContext extends BaseService
         if (routeService != null) {
             if (getRouteStatus(routeId).isStopped()) {
                 try {
-                    routeService.setRemovingRoutes(true);
-                    shutdownRouteService(routeService, loggingLevel);
-                    routeServices.remove(routeId);
-                    // remove route from startup order as well, as it was
-                    // removed
-                    routeStartupOrder.removeIf(order -> order.getRoute().getId().equals(routeId));
-
-                    // from the route which we have removed, then remove all its
-                    // private endpoints
-                    // (eg the endpoints which are not in use by other routes)
-                    Set<Endpoint> toRemove = new LinkedHashSet<>();
-                    for (Endpoint endpoint : endpointsInUse.get(routeId)) {
-                        // how many times is the endpoint in use
-                        int count = 0;
-                        for (Set<Endpoint> endpointSet : endpointsInUse.values()) {
-                            if (endpointSet.contains(endpoint)) {
-                                count++;
-                            }
-                        }
-                        // notice we will count ourselves so if there is only 1
-                        // then its safe to remove
-                        if (count <= 1) {
-                            toRemove.add(endpoint);
-                        }
-                    }
-                    for (Endpoint endpoint : toRemove) {
-                        LOG.debug("Removing: {} which was only in use by route: {}", endpoint, routeId);
-                        removeEndpoint(endpoint);
-                    }
+                    doRemove(routeId, loggingLevel, routeService, endpointsInUse);
                 } catch (Exception e) {
                     DefaultRouteError.set(this, routeId, Phase.REMOVE, e);
                     throw e;
@@ -1258,6 +1235,39 @@ public abstract class AbstractCamelContext extends BaseService
         return false;
     }
 
+    private void doRemove(
+            String routeId, LoggingLevel loggingLevel, RouteService routeService, Map<String, Set<Endpoint>> endpointsInUse) {
+        routeService.setRemovingRoutes(true);
+        shutdownRouteService(routeService, loggingLevel);
+        routeServices.remove(routeId);
+        // remove route from startup order as well, as it was
+        // removed
+        routeStartupOrder.removeIf(order -> order.getRoute().getId().equals(routeId));
+
+        // from the route which we have removed, then remove all its
+        // private endpoints
+        // (eg the endpoints which are not in use by other routes)
+        Set<Endpoint> toRemove = new LinkedHashSet<>();
+        for (Endpoint endpoint : endpointsInUse.get(routeId)) {
+            // how many times is the endpoint in use
+            int count = 0;
+            for (Set<Endpoint> endpointSet : endpointsInUse.values()) {
+                if (endpointSet.contains(endpoint)) {
+                    count++;
+                }
+            }
+            // notice we will count ourselves so if there is only 1
+            // then its safe to remove
+            if (count <= 1) {
+                toRemove.add(endpoint);
+            }
+        }
+        for (Endpoint endpoint : toRemove) {
+            LOG.debug("Removing: {} which was only in use by route: {}", endpoint, routeId);
+            removeEndpoint(endpoint);
+        }
+    }
+
     public void suspendRoute(String routeId) throws Exception {
         suspendRoute(routeId, getShutdownStrategy().getTimeout(), getShutdownStrategy().getTimeUnit());
     }


(camel) 02/04: (chores) camel-core: removed unused exceptions from the AbstractCamelContext

Posted by or...@apache.org.
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

commit 5d7727fe49f074f4c0a4d36c6f343da7211574fc
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Jan 4 16:16:11 2024 +0100

    (chores) camel-core: removed unused exceptions from the AbstractCamelContext
---
 .../org/apache/camel/impl/engine/AbstractCamelContext.java | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
index 7561d8af92b..38c10922010 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java
@@ -666,7 +666,7 @@ public abstract class AbstractCamelContext extends BaseService
     }
 
     @Override
-    public void removeEndpoint(Endpoint endpoint) throws Exception {
+    public void removeEndpoint(Endpoint endpoint) {
         Endpoint oldEndpoint = null;
         NormalizedUri oldKey = null;
         for (Map.Entry<NormalizedUri, Endpoint> entry : endpoints.entrySet()) {
@@ -690,7 +690,7 @@ public abstract class AbstractCamelContext extends BaseService
     }
 
     @Override
-    public Collection<Endpoint> removeEndpoints(String uri) throws Exception {
+    public Collection<Endpoint> removeEndpoints(String uri) {
         Collection<Endpoint> answer = new ArrayList<>();
         Endpoint oldEndpoint = endpoints.remove(getEndpointKey(uri));
         if (oldEndpoint != null) {
@@ -1329,7 +1329,7 @@ public abstract class AbstractCamelContext extends BaseService
     }
 
     @Override
-    public void addPrototypeService(Object object) throws Exception {
+    public void addPrototypeService(Object object) {
         internalServiceManager.addService(this, object, false, true, false);
     }
 
@@ -1366,7 +1366,7 @@ public abstract class AbstractCamelContext extends BaseService
     }
 
     @Override
-    public void deferStartService(Object object, boolean stopOnShutdown) throws Exception {
+    public void deferStartService(Object object, boolean stopOnShutdown) {
         internalServiceManager.deferStartService(this, object, stopOnShutdown, false);
     }
 
@@ -3192,7 +3192,7 @@ public abstract class AbstractCamelContext extends BaseService
         }
     }
 
-    protected synchronized void stopRouteService(RouteService routeService, LoggingLevel loggingLevel) throws Exception {
+    protected synchronized void stopRouteService(RouteService routeService, LoggingLevel loggingLevel) {
         routeService.stop();
         logRouteState(routeService.getRoute(), "Stopped", loggingLevel);
     }
@@ -3201,12 +3201,12 @@ public abstract class AbstractCamelContext extends BaseService
         shutdownRouteService(routeService, LoggingLevel.INFO);
     }
 
-    protected synchronized void shutdownRouteService(RouteService routeService, LoggingLevel loggingLevel) throws Exception {
+    protected synchronized void shutdownRouteService(RouteService routeService, LoggingLevel loggingLevel) {
         routeService.shutdown();
         logRouteState(routeService.getRoute(), "Shutdown", loggingLevel);
     }
 
-    protected synchronized void suspendRouteService(RouteService routeService) throws Exception {
+    protected synchronized void suspendRouteService(RouteService routeService) {
         routeService.setRemovingRoutes(false);
         routeService.suspend();
         logRouteState(routeService.getRoute(), "Suspended", LoggingLevel.INFO);