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 2022/10/13 16:52:42 UTC
[camel] branch main updated: (chores) camel-base-engine: avoid shadowing variables
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 01826e6a4b2 (chores) camel-base-engine: avoid shadowing variables
01826e6a4b2 is described below
commit 01826e6a4b23cdbec9c35f01b4ed030b65e15fe0
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Oct 13 16:35:59 2022 +0200
(chores) camel-base-engine: avoid shadowing variables
---
.../camel/impl/engine/AbstractCamelContext.java | 55 ++++++++++++----------
1 file changed, 29 insertions(+), 26 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 f5c499951d5..08e61128a85 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
@@ -1409,11 +1409,11 @@ public abstract class AbstractCamelContext extends BaseService
RouteService routeService = routeServices.get(routeId);
if (routeService != null) {
try {
- List<RouteStartupOrder> routes = new ArrayList<>(1);
+ List<RouteStartupOrder> routeList = new ArrayList<>(1);
RouteStartupOrder order = new DefaultRouteStartupOrder(1, routeService.getRoute(), routeService);
- routes.add(order);
+ routeList.add(order);
- getShutdownStrategy().shutdown(this, routes, timeout, timeUnit);
+ getShutdownStrategy().shutdown(this, routeList, timeout, timeUnit);
// must stop route service as well (and remove the routes from
// management)
stopRouteService(routeService, removingRoutes, loggingLevel);
@@ -1458,8 +1458,8 @@ public abstract class AbstractCamelContext extends BaseService
for (Endpoint endpoint : endpointsInUse.get(routeId)) {
// how many times is the endpoint in use
int count = 0;
- for (Set<Endpoint> endpoints : endpointsInUse.values()) {
- if (endpoints.contains(endpoint)) {
+ for (Set<Endpoint> endpointSet : endpointsInUse.values()) {
+ if (endpointSet.contains(endpoint)) {
count++;
}
}
@@ -1501,12 +1501,12 @@ public abstract class AbstractCamelContext extends BaseService
RouteService routeService = routeServices.get(routeId);
if (routeService != null) {
- List<RouteStartupOrder> routes = new ArrayList<>(1);
+ List<RouteStartupOrder> routeList = new ArrayList<>(1);
Route route = routeService.getRoute();
RouteStartupOrder order = new DefaultRouteStartupOrder(1, route, routeService);
- routes.add(order);
+ routeList.add(order);
- getShutdownStrategy().suspend(this, routes, timeout, timeUnit);
+ getShutdownStrategy().suspend(this, routeList, timeout, timeUnit);
// must suspend route service as well
suspendRouteService(routeService);
// must suspend the route as well
@@ -2528,7 +2528,7 @@ public abstract class AbstractCamelContext extends BaseService
}
private String doGetVersion() {
- String version = null;
+ String resolvedVersion = null;
InputStream is = null;
// try to load from maven properties first
@@ -2538,7 +2538,7 @@ public abstract class AbstractCamelContext extends BaseService
.getResourceAsStream("/META-INF/maven/org.apache.camel/camel-base-engine/pom.properties");
if (is != null) {
p.load(is);
- version = p.getProperty("version", "");
+ resolvedVersion = p.getProperty("version", "");
}
} catch (Exception e) {
// ignore
@@ -2549,22 +2549,22 @@ public abstract class AbstractCamelContext extends BaseService
}
// fallback to using Java API
- if (version == null) {
+ if (resolvedVersion == null) {
Package aPackage = getClass().getPackage();
if (aPackage != null) {
- version = aPackage.getImplementationVersion();
- if (version == null) {
- version = aPackage.getSpecificationVersion();
+ resolvedVersion = aPackage.getImplementationVersion();
+ if (resolvedVersion == null) {
+ resolvedVersion = aPackage.getSpecificationVersion();
}
}
}
- if (version == null) {
+ if (resolvedVersion == null) {
// we could not compute the version so use a blank
- version = "";
+ resolvedVersion = "";
}
- return version;
+ return resolvedVersion;
}
@Override
@@ -3290,8 +3290,7 @@ public abstract class AbstractCamelContext extends BaseService
}
// start management strategy before lifecycles are started
- ManagementStrategy managementStrategy = getManagementStrategy();
- startService(managementStrategy);
+ startService(getManagementStrategy());
// start lifecycle strategies
if (!lifecycleStrategies.isEmpty()) {
@@ -3779,8 +3778,8 @@ public abstract class AbstractCamelContext extends BaseService
internalRouteStartupManager.safelyStartRouteServices(true, true, true, false, addingRoutes, routeService);
// start route services if it was configured to auto startup
// and we are not adding routes
- boolean autoStartup = routeService.isAutoStartup();
- if (!addingRoutes || autoStartup) {
+ boolean isAutoStartup = routeService.isAutoStartup();
+ if (!addingRoutes || isAutoStartup) {
// start the route since auto start is enabled or we are
// starting a route (not adding new routes)
routeService.start();
@@ -4307,11 +4306,7 @@ public abstract class AbstractCamelContext extends BaseService
= getBootstrapFactoryFinder().newInstance(Debugger.FACTORY, DebuggerFactory.class).orElse(null);
if (df != null) {
LOG.info("Detected: {} JAR (Enabling Camel Debugging)", df);
- setDebugging(true);
- Debugger debugger = df.createDebugger(this);
- if (debugger != null) {
- setDebugger(debugger);
- }
+ enableDebugging(df);
}
} catch (Exception e) {
LOG.warn("Cannot create JmxManagementStrategyFactory. Will fallback and disable JMX.", e);
@@ -4341,6 +4336,14 @@ public abstract class AbstractCamelContext extends BaseService
}
}
+ private void enableDebugging(DebuggerFactory df) throws Exception {
+ setDebugging(true);
+ Debugger newDebugger = df.createDebugger(this);
+ if (newDebugger != null) {
+ setDebugger(newDebugger);
+ }
+ }
+
private static String getJvmUptime() {
try {
return TimeUtils.printDuration(ManagementFactory.getRuntimeMXBean().getUptime());