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-2511: Sqoop2: Findbugs: Fix warnings in connector-generic-jdbc module
Date Thu, 20 Aug 2015 23:20:23 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 daaa75762 -> cd8621a20


SQOOP-2511: Sqoop2: Findbugs: Fix warnings in connector-generic-jdbc 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/cd8621a2
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/cd8621a2
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/cd8621a2

Branch: refs/heads/sqoop2
Commit: cd8621a20cc372e392285562a3200dc4e2773420
Parents: daaa757
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Aug 20 16:20:10 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Thu Aug 20 16:20:10 2015 -0700

----------------------------------------------------------------------
 .../connector/jdbc/GenericJdbcPartitioner.java    | 18 +++++++++---------
 .../connector/jdbc/configuration/LinkConfig.java  |  4 ++--
 2 files changed, 11 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/cd8621a2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
index a99b3a9..2a42ed4 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/GenericJdbcPartitioner.java
@@ -37,7 +37,7 @@ import org.apache.sqoop.job.etl.PartitionerContext;
 
 public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration, FromJobConfiguration>
{
 
-  private static final BigDecimal NUMERIC_MIN_INCREMENT = new BigDecimal(10000 * Double.MIN_VALUE);
+  private static final BigDecimal NUMERIC_MIN_INCREMENT = BigDecimal.valueOf(10000 * Double.MIN_VALUE);
 
 
   private long numberPartitions;
@@ -149,7 +149,8 @@ public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration,
FromJ
         minDateValue = Time.valueOf(partitionMinValue).getTime();
         maxDateValue = Time.valueOf(partitionMaxValue).getTime();
         break;
-      case Types.TIMESTAMP:
+      // Here should be the type of Types.TIMESTAMP:
+      default:
         sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
         minDateValue = Timestamp.valueOf(partitionMinValue).getTime();
         maxDateValue = Timestamp.valueOf(partitionMaxValue).getTime();
@@ -190,7 +191,8 @@ public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration,
FromJ
           objUB = new Time(upperBound);
 
           break;
-        case Types.TIMESTAMP:
+        // Here should be the type of Types.TIMESTAMP:
+        default:
           objLB = new Timestamp(lowerBound);
           objUB = new Timestamp(upperBound);
           break;
@@ -211,7 +213,8 @@ public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration,
FromJ
         objLB = new Time(upperBound);
         objUB = new Time(maxDateValue);
         break;
-      case Types.TIMESTAMP:
+      // Here should be the type of Types.TIMESTAMP:
+      default:
         objLB = new Timestamp(upperBound);
         objUB = new Timestamp(maxDateValue);
         break;
@@ -473,12 +476,9 @@ public class GenericJdbcPartitioner extends Partitioner<LinkConfiguration,
FromJ
   }
 
   private Boolean parseBooleanValue(String value) {
-    if (value == null) {
-      return null;
-    }
-    if (value.equals("1")) {
+    if ("1".equals(value)) {
       return Boolean.TRUE;
-    } else if (value.equals("0")) {
+    } else if ("0".equals(value)) {
       return Boolean.FALSE;
     } else {
       return Boolean.parseBoolean(value);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/cd8621a2/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
----------------------------------------------------------------------
diff --git a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
index 9a71f36..885c6f5 100644
--- a/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
+++ b/connector/connector-generic-jdbc/src/main/java/org/apache/sqoop/connector/jdbc/configuration/LinkConfig.java
@@ -26,6 +26,7 @@ import org.apache.sqoop.validation.validators.NotEmpty;
 import org.apache.sqoop.validation.validators.ClassAvailable;
 import org.apache.sqoop.validation.validators.StartsWith;
 
+import java.sql.Connection;
 import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.Map;
@@ -54,8 +55,7 @@ public class LinkConfig {
     @Override
     public void validate(LinkConfig linkConfig) {
       // See if we can connect to the database
-      try {
-        DriverManager.getConnection(linkConfig.connectionString, linkConfig.username, linkConfig.password);
+      try (Connection tempConnection = DriverManager.getConnection(linkConfig.connectionString,
linkConfig.username, linkConfig.password)) {
       } catch (SQLException e) {
         addMessage(Status.WARNING, "Can't connect to the database with given credentials:
" + e.getMessage());
       }


Mime
View raw message