sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2485: Sqoop2: Findbugs: Fix smaller-ish warnings in core module
Date Thu, 20 Aug 2015 16:19:42 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 5b5042c1f -> b62c3dec8


SQOOP-2485: Sqoop2: Findbugs: Fix smaller-ish warnings in core module

(Colin Ma via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/b62c3dec
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/b62c3dec
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/b62c3dec

Branch: refs/heads/sqoop2
Commit: b62c3dec82225a5960d982473e9334508c91a1ce
Parents: 5b5042c
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Aug 20 09:19:24 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Thu Aug 20 09:19:24 2015 -0700

----------------------------------------------------------------------
 .../org/apache/sqoop/audit/AuditLoggerManager.java    | 14 +++-----------
 .../org/apache/sqoop/connector/ConnectorManager.java  |  4 ++--
 .../sqoop/core/PropertiesConfigurationProvider.java   |  2 +-
 .../main/java/org/apache/sqoop/core/SqoopServer.java  |  7 ++++---
 .../main/java/org/apache/sqoop/driver/JobManager.java |  6 +++---
 .../org/apache/sqoop/repository/JdbcRepository.java   |  2 +-
 .../sqoop/repository/JdbcTransactionIsolation.java    |  3 ++-
 .../java/org/apache/sqoop/repository/Repository.java  | 12 ++++++++----
 8 files changed, 24 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/audit/AuditLoggerManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/audit/AuditLoggerManager.java b/core/src/main/java/org/apache/sqoop/audit/AuditLoggerManager.java
index 728127b..5e5d7ab 100644
--- a/core/src/main/java/org/apache/sqoop/audit/AuditLoggerManager.java
+++ b/core/src/main/java/org/apache/sqoop/audit/AuditLoggerManager.java
@@ -63,15 +63,6 @@ public class AuditLoggerManager implements Reconfigurable {
     return instance;
   }
 
-  /**
-   * Allows to set instance in case that it's need.
-   *
-   * @param newInstance New instance
-   */
-  public void setInstance(AuditLoggerManager newInstance) {
-    instance = newInstance;
-  }
-
   public AuditLoggerManager() {
     loggers = new ArrayList<AuditLogger>();
   }
@@ -95,10 +86,11 @@ public class AuditLoggerManager implements Reconfigurable {
         AuditLoggerConstants.PREFIX_AUDITLOGGER_CONFIG);
 
     // Initialize audit loggers
-    for (String key : auditLoggerProps.keySet()) {
+    for (Map.Entry<String, String> entry : auditLoggerProps.entrySet()) {
+      String key = entry.getKey();
       if (key.endsWith(AuditLoggerConstants.SUFFIX_AUDITLOGGER_CLASS)) {
         String loggerName = key.substring(0, key.indexOf("."));
-        String loggerClassName = auditLoggerProps.get(key);
+        String loggerClassName = entry.getValue();
 
         if (loggerClassName == null || loggerClassName.trim().length() == 0) {
           throw new SqoopException(AuditLoggerError.AUDIT_0001,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
index a16fceb..b64d6fd 100644
--- a/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
+++ b/core/src/main/java/org/apache/sqoop/connector/ConnectorManager.java
@@ -196,8 +196,8 @@ public class ConnectorManager implements Reconfigurable {
     try {
       rtx = repository.getTransaction();
       rtx.begin();
-      for (String name : handlerMap.keySet()) {
-        ConnectorHandler handler = handlerMap.get(name);
+      for (Map.Entry<String, ConnectorHandler> entry : handlerMap.entrySet()) {
+        ConnectorHandler handler = entry.getValue();
         MConnector newConnector = handler.getConnectorConfigurable();
         MConnector registeredConnector = repository.registerConnector(newConnector, autoUpgrade);
         // Set the registered connector in the database to the connector configurable instance

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
b/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
index f1c4820..2e2d068 100644
--- a/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
+++ b/core/src/main/java/org/apache/sqoop/core/PropertiesConfigurationProvider.java
@@ -159,7 +159,7 @@ public class PropertiesConfigurationProvider implements ConfigurationProvider
{
     private synchronized void loadSleepTime() {
       try {
         String value = configuration.get(PROPERTIES_PROVIDER_SLEEP);
-        sleepTime = Long.valueOf(value);
+        sleepTime = Long.parseLong(value);
       } catch(Exception e) {
         LOG.debug("Can't load sleeping period from configuration file,"
           + " using default value " + DEFAULT_SLEEP_TIME, e);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/core/SqoopServer.java b/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
index e78e4d9..75cea65 100644
--- a/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
+++ b/core/src/main/java/org/apache/sqoop/core/SqoopServer.java
@@ -19,6 +19,7 @@ package org.apache.sqoop.core;
 
 import org.apache.log4j.Logger;
 import org.apache.sqoop.audit.AuditLoggerManager;
+import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.driver.Driver;
 import org.apache.sqoop.driver.JobManager;
@@ -58,9 +59,9 @@ public class SqoopServer {
       Driver.getInstance().initialize();
       JobManager.getInstance().initialize();
       LOG.info("Sqoop server has successfully boot up");
-    } catch (Exception ex) {
-      LOG.error("Server startup failure", ex);
-      throw new RuntimeException("Failure in server initialization", ex);
+    } catch (RuntimeException | ClassNotFoundException | IllegalAccessException | InstantiationException
e) {
+      LOG.error("Server startup failure", e);
+      throw new RuntimeException("Failure in server initialization", e);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/driver/JobManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/driver/JobManager.java b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
index d4e0655..44416c4 100644
--- a/core/src/main/java/org/apache/sqoop/driver/JobManager.java
+++ b/core/src/main/java/org/apache/sqoop/driver/JobManager.java
@@ -279,7 +279,7 @@ public class JobManager implements Reconfigurable {
     prepareJob(jobRequest);
     // Make sure that this job id is not currently running and submit the job
     // only if it's not.
-    synchronized (getClass()) {
+    synchronized (JobManager.class) {
       MSubmission lastSubmission = RepositoryManager.getInstance().getRepository()
           .findLastSubmissionForJob(jobId);
       if (lastSubmission != null && lastSubmission.getStatus().isRunning()) {
@@ -561,8 +561,8 @@ public class JobManager implements Reconfigurable {
       }
 
       RepositoryManager.getInstance().getRepository().updateJob(job);
-    } catch(Exception ex) {
-      LOG.error("Exception when invoking destroyer on job success", ex);
+    } catch (RuntimeException e) {
+      LOG.error("RuntimeException when invoking destroyer on job success", e);
       submission.setStatus(SubmissionStatus.FAILED);
     }
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
index c09b77b..9a4853b 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -729,7 +729,7 @@ public class JdbcRepository extends Repository {
    */
   @Override
   public void updateJobConfig(final long jobId, final MConfig config, final MConfigUpdateEntityType
type) {
-    updateJobConfig(jobId, config, null);
+    updateJobConfig(jobId, config, type, null);
   }
   /**
    * {@inheritDoc}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/repository/JdbcTransactionIsolation.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcTransactionIsolation.java
b/core/src/main/java/org/apache/sqoop/repository/JdbcTransactionIsolation.java
index 2b1c8ce..1d7c1c5 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcTransactionIsolation.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcTransactionIsolation.java
@@ -18,6 +18,7 @@
 package org.apache.sqoop.repository;
 
 import java.sql.Connection;
+import java.util.Locale;
 
 public enum JdbcTransactionIsolation {
 
@@ -50,6 +51,6 @@ public enum JdbcTransactionIsolation {
     if (name == null || name.trim().length() == 0) {
       return null;
     }
-    return valueOf(name.trim().toUpperCase());
+    return valueOf(name.trim().toUpperCase(Locale.getDefault()));
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/b62c3dec/core/src/main/java/org/apache/sqoop/repository/Repository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/Repository.java b/core/src/main/java/org/apache/sqoop/repository/Repository.java
index 8cbff99..610876c 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -459,11 +459,15 @@ public abstract class Repository {
   protected abstract void deleteLinkInputs(long linkId, RepositoryTransaction tx);
 
   private void deletelinksAndJobInputs(List<MLink> links, List<MJob> jobs, RepositoryTransaction
tx) {
-    for (MJob job : jobs) {
-      deleteJobInputs(job.getPersistenceId(), tx);
+    if (jobs != null) {
+      for (MJob job : jobs) {
+        deleteJobInputs(job.getPersistenceId(), tx);
+      }
     }
-    for (MLink link : links) {
-      deleteLinkInputs(link.getPersistenceId(), tx);
+    if (links != null) {
+      for (MLink link : links) {
+        deleteLinkInputs(link.getPersistenceId(), tx);
+      }
     }
   }
 


Mime
View raw message