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-2512: Sqoop2: Findbugs: Fix warnings in connector-ftp, connector-sftp and connector-hdfs module
Date Thu, 20 Aug 2015 16:10:56 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 7f7862895 -> d1c47b22d


SQOOP-2512: Sqoop2: Findbugs: Fix warnings in connector-ftp, connector-sftp and connector-hdfs
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/d1c47b22
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/d1c47b22
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/d1c47b22

Branch: refs/heads/sqoop2
Commit: d1c47b22d8f4355de3a13eb78376fbbe2aa48334
Parents: 7f78628
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Aug 20 09:10:38 2015 -0700
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Thu Aug 20 09:10:38 2015 -0700

----------------------------------------------------------------------
 .../connector/ftp/ftpclient/FtpConnectorClient.java     |  5 +++--
 .../org/apache/sqoop/connector/hdfs/HdfsLoader.java     |  2 +-
 .../org/apache/sqoop/connector/hdfs/HdfsPartition.java  | 12 ++++--------
 .../apache/sqoop/connector/hdfs/HdfsPartitioner.java    |  6 +-----
 .../connector/sftp/sftpclient/SftpConnectorClient.java  |  5 +++--
 5 files changed, 12 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/d1c47b22/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/ftpclient/FtpConnectorClient.java
----------------------------------------------------------------------
diff --git a/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/ftpclient/FtpConnectorClient.java
b/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/ftpclient/FtpConnectorClient.java
index 7a65173..a85d3e2 100644
--- a/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/ftpclient/FtpConnectorClient.java
+++ b/connector/connector-ftp/src/main/java/org/apache/sqoop/connector/ftp/ftpclient/FtpConnectorClient.java
@@ -31,6 +31,7 @@ import org.apache.sqoop.etl.io.DataReader;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 import java.util.UUID;
 
 /**
@@ -161,8 +162,8 @@ public class FtpConnectorClient {
         String record;
         while ((record = reader.readTextRecord()) != null) {
           LOG.info("Writing record to FTP server:" + record);
-          output.write(record.getBytes());
-          output.write(("\n").getBytes());
+          output.write(record.getBytes(Charset.forName("UTF-8")));
+          output.write(("\n").getBytes(Charset.forName("UTF-8")));
           recordsWritten++;
         }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/d1c47b22/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
index 96913e8..948b1b6 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsLoader.java
@@ -72,7 +72,7 @@ public class HdfsLoader extends Loader<LinkConfiguration, ToJobConfiguration>
{
         if (codec instanceof Configurable) {
           ((Configurable) codec).setConf(conf);
         }
-      } catch (Exception e) {
+      } catch (RuntimeException|InstantiationException|IllegalAccessException e) {
         throw new SqoopException(HdfsConnectorError.GENERIC_HDFS_CONNECTOR_0004, codecname,
e);
       }
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/d1c47b22/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartition.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartition.java
b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartition.java
index b801356..644de60 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartition.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartition.java
@@ -46,10 +46,10 @@ public class HdfsPartition extends Partition {
       this.lenFiles += length;
     }
     this.numFiles = files.length;
-    this.files = files;
-    this.offsets = offsets;
-    this.lengths = lengths;
-    this.locations = locations;
+    this.files = files.clone();
+    this.offsets = offsets.clone();
+    this.lengths = lengths.clone();
+    this.locations = locations.clone();
   }
 
   public long getLengthOfFiles() {
@@ -72,10 +72,6 @@ public class HdfsPartition extends Partition {
     return lengths[i];
   }
 
-  public String[] getLocations() {
-    return locations;
-  }
-
   @Override
   public void readFields(DataInput in) throws IOException {
     numFiles = in.readInt();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/d1c47b22/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
----------------------------------------------------------------------
diff --git a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
index dcc1157..119955d 100644
--- a/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
+++ b/connector/connector-hdfs/src/main/java/org/apache/sqoop/connector/hdfs/HdfsPartitioner.java
@@ -166,9 +166,6 @@ public class HdfsPartitioner extends Partitioner<LinkConfiguration,
FromJobConfi
       long maxSize, long minSizeNode, long minSizeRack,
       List<Partition> partitions) throws IOException {
 
-    // all blocks for all the files in input set
-    OneFileInfo[] files;
-
     // mapping from a rack name to the list of blocks it has
     HashMap<String, List<OneBlockInfo>> rackToBlocks =
                               new HashMap<String, List<OneBlockInfo>>();
@@ -181,14 +178,13 @@ public class HdfsPartitioner extends Partitioner<LinkConfiguration,
FromJobConfi
     HashMap<String, List<OneBlockInfo>> nodeToBlocks =
                               new HashMap<String, List<OneBlockInfo>>();
 
-    files = new OneFileInfo[paths.size()];
     if (paths.size() == 0) {
       return;
     }
 
     // populate all the blocks for all files
     for (int i = 0; i < paths.size(); i++) {
-      files[i] = new OneFileInfo(paths.get(i), conf, isSplitable(conf, paths.get(i)),
+      new OneFileInfo(paths.get(i), conf, isSplitable(conf, paths.get(i)),
                                  rackToBlocks, blockToNodes, nodeToBlocks,
                                  rackToNodes, maxSize);
     }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/d1c47b22/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/sftpclient/SftpConnectorClient.java
----------------------------------------------------------------------
diff --git a/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/sftpclient/SftpConnectorClient.java
b/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/sftpclient/SftpConnectorClient.java
index a8418ab..7cafed2 100644
--- a/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/sftpclient/SftpConnectorClient.java
+++ b/connector/connector-sftp/src/main/java/org/apache/sqoop/connector/sftp/sftpclient/SftpConnectorClient.java
@@ -33,6 +33,7 @@ import org.apache.sqoop.etl.io.DataReader;
 
 import java.io.IOException;
 import java.io.OutputStream;
+import java.nio.charset.Charset;
 import java.util.Properties;
 
 /**
@@ -143,8 +144,8 @@ public class SftpConnectorClient {
       LOG.info("Opened OutputStream to path: " + path);
       String record;
       while ((record = reader.readTextRecord()) != null) {
-        out.write(record.getBytes());
-        out.write(("\n").getBytes());
+        out.write(record.getBytes(Charset.forName("UTF-8")));
+        out.write(("\n").getBytes(Charset.forName("UTF-8")));
         recordsWritten++;
       }
     } catch (Exception e) {


Mime
View raw message