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 08:39:38 UTC

[camel] branch main updated: (chores) 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 793b450d997 (chores) avoid shadowing variables
793b450d997 is described below

commit 793b450d99756d1ccb3541ff53428ed7f2f6252a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Thu Oct 13 09:30:58 2022 +0200

    (chores) avoid shadowing variables
    
    Components:
    - camel-arangodb
    - camel-ehcache
    - camel-git
    - camel-printer
---
 .../org/apache/camel/component/arangodb/ArangoDbComponent.java    | 6 +++---
 .../java/org/apache/camel/component/ehcache/EhcacheComponent.java | 4 +---
 .../apache/camel/component/git/consumer/AbstractGitConsumer.java  | 5 ++---
 .../java/org/apache/camel/component/git/producer/GitProducer.java | 8 ++------
 .../component/google/functions/GoogleCloudFunctionsComponent.java | 6 +++---
 .../java/org/apache/camel/component/printer/PrinterProducer.java  | 8 ++++----
 6 files changed, 15 insertions(+), 22 deletions(-)

diff --git a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
index f93424a4810..2c8a010953c 100644
--- a/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
+++ b/components/camel-arangodb/src/main/java/org/apache/camel/component/arangodb/ArangoDbComponent.java
@@ -44,10 +44,10 @@ public class ArangoDbComponent extends DefaultComponent {
             throw new IllegalArgumentException("Database name must be specified.");
         }
 
-        final ArangoDbConfiguration configuration
+        final ArangoDbConfiguration configurationClone
                 = this.configuration != null ? this.configuration.copy() : new ArangoDbConfiguration();
-        configuration.setDatabase(remaining);
-        Endpoint endpoint = new ArangoDbEndpoint(uri, this, configuration);
+        configurationClone.setDatabase(remaining);
+        Endpoint endpoint = new ArangoDbEndpoint(uri, this, configurationClone);
         setProperties(endpoint, parameters);
         return endpoint;
     }
diff --git a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheComponent.java b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheComponent.java
index 65cf5f912f7..e0ff6dbfa24 100644
--- a/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheComponent.java
+++ b/components/camel-ehcache/src/main/java/org/apache/camel/component/ehcache/EhcacheComponent.java
@@ -58,9 +58,7 @@ public class EhcacheComponent extends DefaultComponent {
 
     @Override
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
-        EhcacheConfiguration configuration = this.configuration.copy();
-
-        EhcacheEndpoint endpoint = new EhcacheEndpoint(uri, this, remaining, configuration);
+        EhcacheEndpoint endpoint = new EhcacheEndpoint(uri, this, remaining, this.configuration.copy());
         setProperties(endpoint, parameters);
         return endpoint;
     }
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
index 0fb735ee470..a99156224ae 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
@@ -59,16 +59,15 @@ public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
 
     private Repository getLocalRepository() throws IOException {
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = null;
         try {
-            repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment() // scan environment GIT_* variables
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
                     .findGitDir() // scan up the file system tree
                     .build();
         } catch (IOException e) {
             LOG.error("There was an error, cannot open {} repository", endpoint.getLocalPath());
             throw e;
         }
-        return repo;
     }
 
     protected Repository getRepository() {
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index 1f02d9ae0b5..083e06ec8e7 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -646,19 +646,15 @@ public class GitProducer extends DefaultProducer {
 
     private Repository getLocalRepository() throws IOException {
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = null;
         try {
-            repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment() // scan
-                    // environment
-                    // GIT_*
-                    // variables
+            // scan environment GIT_* variables
+            return builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment()
                     .findGitDir() // scan up the file system tree
                     .build();
         } catch (IOException e) {
             LOG.error("There was an error, cannot open {} repository", endpoint.getLocalPath());
             throw e;
         }
-        return repo;
     }
 
     private void updateExchange(Exchange exchange, Object body) {
diff --git a/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsComponent.java b/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsComponent.java
index abafbd6c015..b1a3412c4d9 100644
--- a/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsComponent.java
+++ b/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsComponent.java
@@ -41,11 +41,11 @@ public class GoogleCloudFunctionsComponent extends DefaultComponent {
         if (remaining == null || remaining.trim().length() == 0) {
             throw new IllegalArgumentException("Function name must be specified.");
         }
-        final GoogleCloudFunctionsConfiguration configuration
+        final GoogleCloudFunctionsConfiguration configurationCopy
                 = this.configuration != null ? this.configuration.copy() : new GoogleCloudFunctionsConfiguration();
-        configuration.setFunctionName(remaining);
+        configurationCopy.setFunctionName(remaining);
 
-        Endpoint endpoint = new GoogleCloudFunctionsEndpoint(uri, this, configuration);
+        Endpoint endpoint = new GoogleCloudFunctionsEndpoint(uri, this, configurationCopy);
         setProperties(endpoint, parameters);
         return endpoint;
     }
diff --git a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
index 27a9ec7fe2c..9fd2d9b8b15 100644
--- a/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
+++ b/components/camel-printer/src/main/java/org/apache/camel/component/printer/PrinterProducer.java
@@ -116,11 +116,11 @@ public class PrinterProducer extends DefaultProducer {
     }
 
     private PrintService assignPrintService() throws PrintException {
-        PrintService printService;
+        PrintService retPrintService;
 
         if ((config.getHostname().equalsIgnoreCase("localhost"))
                 && (config.getPrintername().equalsIgnoreCase("default"))) {
-            printService = PrintServiceLookup.lookupDefaultPrintService();
+            retPrintService = PrintServiceLookup.lookupDefaultPrintService();
         } else {
             PrintService[] services = PrintServiceLookup.lookupPrintServices(null, null);
             String name;
@@ -141,9 +141,9 @@ public class PrinterProducer extends DefaultProducer {
                         "No printer found with name: " + printer
                                          + ". Please verify that the host and printer are registered and reachable from this machine.");
             }
-            printService = services[position];
+            retPrintService = services[position];
         }
-        return printService;
+        return retPrintService;
     }
 
     private int findPrinter(PrintService[] services, String printer) {