HADOOP-11429. Findbugs warnings in hadoop extras. Contributed by Varun Saxena.
This commit is contained in:
parent
2860eeb14a
commit
02b21b7131
|
@ -641,6 +641,9 @@ Release 2.7.0 - UNRELEASED
|
||||||
HADOOP-11431. clean up redundant maven-site-plugin configuration.
|
HADOOP-11431. clean up redundant maven-site-plugin configuration.
|
||||||
(Herve Boutemy via wheat9)
|
(Herve Boutemy via wheat9)
|
||||||
|
|
||||||
|
HADOOP-11429. Findbugs warnings in hadoop extras.
|
||||||
|
(Varun Saxena via wheat9)
|
||||||
|
|
||||||
Release 2.6.0 - 2014-11-18
|
Release 2.6.0 - 2014-11-18
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -238,11 +238,10 @@ public class DistCh extends DistTool {
|
||||||
|
|
||||||
Text key = new Text();
|
Text key = new Text();
|
||||||
FileOperation value = new FileOperation();
|
FileOperation value = new FileOperation();
|
||||||
SequenceFile.Reader in = null;
|
|
||||||
long prev = 0L;
|
long prev = 0L;
|
||||||
int count = 0; //count src
|
int count = 0; //count src
|
||||||
try {
|
try (SequenceFile.Reader in = new SequenceFile.Reader(fs, srcs, job)) {
|
||||||
for(in = new SequenceFile.Reader(fs, srcs, job); in.next(key, value); ) {
|
for ( ; in.next(key, value); ) {
|
||||||
long curr = in.getPosition();
|
long curr = in.getPosition();
|
||||||
long delta = curr - prev;
|
long delta = curr - prev;
|
||||||
if (++count > targetcount) {
|
if (++count > targetcount) {
|
||||||
|
@ -252,9 +251,6 @@ public class DistCh extends DistTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
long remaining = fs.getFileStatus(srcs).getLen() - prev;
|
long remaining = fs.getFileStatus(srcs).getLen() - prev;
|
||||||
if (remaining != 0) {
|
if (remaining != 0) {
|
||||||
splits.add(new FileSplit(srcs, prev, remaining, (String[])null));
|
splits.add(new FileSplit(srcs, prev, remaining, (String[])null));
|
||||||
|
@ -449,10 +445,8 @@ public class DistCh extends DistTool {
|
||||||
Path opList = new Path(jobdir, "_" + OP_LIST_LABEL);
|
Path opList = new Path(jobdir, "_" + OP_LIST_LABEL);
|
||||||
jobconf.set(OP_LIST_LABEL, opList.toString());
|
jobconf.set(OP_LIST_LABEL, opList.toString());
|
||||||
int opCount = 0, synCount = 0;
|
int opCount = 0, synCount = 0;
|
||||||
SequenceFile.Writer opWriter = null;
|
try (SequenceFile.Writer opWriter = SequenceFile.createWriter(fs, jobconf, opList, Text.class,
|
||||||
try {
|
FileOperation.class, SequenceFile.CompressionType.NONE)) {
|
||||||
opWriter = SequenceFile.createWriter(fs, jobconf, opList, Text.class,
|
|
||||||
FileOperation.class, SequenceFile.CompressionType.NONE);
|
|
||||||
for(FileOperation op : ops) {
|
for(FileOperation op : ops) {
|
||||||
FileStatus srcstat = fs.getFileStatus(op.src);
|
FileStatus srcstat = fs.getFileStatus(op.src);
|
||||||
if (srcstat.isDirectory() && op.isDifferent(srcstat)) {
|
if (srcstat.isDirectory() && op.isDifferent(srcstat)) {
|
||||||
|
@ -479,8 +473,6 @@ public class DistCh extends DistTool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
opWriter.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkDuplication(fs, opList, new Path(jobdir, "_sorted"), jobconf);
|
checkDuplication(fs, opList, new Path(jobdir, "_sorted"), jobconf);
|
||||||
|
@ -496,9 +488,7 @@ public class DistCh extends DistTool {
|
||||||
SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs,
|
SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs,
|
||||||
new Text.Comparator(), Text.class, FileOperation.class, conf);
|
new Text.Comparator(), Text.class, FileOperation.class, conf);
|
||||||
sorter.sort(file, sorted);
|
sorter.sort(file, sorted);
|
||||||
SequenceFile.Reader in = null;
|
try (SequenceFile.Reader in = new SequenceFile.Reader(fs, sorted, conf)) {
|
||||||
try {
|
|
||||||
in = new SequenceFile.Reader(fs, sorted, conf);
|
|
||||||
FileOperation curop = new FileOperation();
|
FileOperation curop = new FileOperation();
|
||||||
Text prevsrc = null, cursrc = new Text();
|
Text prevsrc = null, cursrc = new Text();
|
||||||
for(; in.next(cursrc, curop); ) {
|
for(; in.next(cursrc, curop); ) {
|
||||||
|
@ -512,9 +502,6 @@ public class DistCh extends DistTool {
|
||||||
curop = new FileOperation();
|
curop = new FileOperation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally {
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
|
@ -24,6 +24,7 @@ import java.io.DataOutput;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -697,16 +698,13 @@ public class DistCpV1 implements Tool {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
List<Path> result = new ArrayList<Path>();
|
List<Path> result = new ArrayList<Path>();
|
||||||
FileSystem fs = srcList.getFileSystem(conf);
|
FileSystem fs = srcList.getFileSystem(conf);
|
||||||
BufferedReader input = null;
|
try (BufferedReader input = new BufferedReader(new InputStreamReader(fs.open(srcList),
|
||||||
try {
|
Charset.forName("UTF-8")))) {
|
||||||
input = new BufferedReader(new InputStreamReader(fs.open(srcList)));
|
|
||||||
String line = input.readLine();
|
String line = input.readLine();
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
result.add(new Path(line));
|
result.add(new Path(line));
|
||||||
line = input.readLine();
|
line = input.readLine();
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
checkAndClose(input);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -957,7 +955,7 @@ public class DistCpV1 implements Tool {
|
||||||
throw new IllegalArgumentException("num_maps not specified in -m");
|
throw new IllegalArgumentException("num_maps not specified in -m");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
conf.setInt(MAX_MAPS_LABEL, Integer.valueOf(args[idx]));
|
conf.setInt(MAX_MAPS_LABEL, Integer.parseInt(args[idx]));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new IllegalArgumentException("Invalid argument to -m: " +
|
throw new IllegalArgumentException("Invalid argument to -m: " +
|
||||||
args[idx]);
|
args[idx]);
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.io.DataOutput;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -96,14 +97,11 @@ abstract class DistTool implements org.apache.hadoop.util.Tool {
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
FileSystem fs = inputfile.getFileSystem(conf);
|
FileSystem fs = inputfile.getFileSystem(conf);
|
||||||
BufferedReader input = null;
|
try (BufferedReader input = new BufferedReader(new InputStreamReader(fs.open(inputfile),
|
||||||
try {
|
Charset.forName("UTF-8")))) {
|
||||||
input = new BufferedReader(new InputStreamReader(fs.open(inputfile)));
|
|
||||||
for(String line; (line = input.readLine()) != null;) {
|
for(String line; (line = input.readLine()) != null;) {
|
||||||
result.add(line);
|
result.add(line);
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
input.close();
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.hadoop.tools;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -155,14 +156,14 @@ public class Logalyzer {
|
||||||
|
|
||||||
//Compare column-wise according to *sortSpec*
|
//Compare column-wise according to *sortSpec*
|
||||||
for(int i=0; i < sortSpec.length; ++i) {
|
for(int i=0; i < sortSpec.length; ++i) {
|
||||||
int column = (Integer.valueOf(sortSpec[i]).intValue());
|
int column = Integer.parseInt(sortSpec[i]);
|
||||||
String c1 = logColumns1[column];
|
String c1 = logColumns1[column];
|
||||||
String c2 = logColumns2[column];
|
String c2 = logColumns2[column];
|
||||||
|
|
||||||
//Compare columns
|
//Compare columns
|
||||||
int comparision = super.compareBytes(
|
int comparision = super.compareBytes(
|
||||||
c1.getBytes(), 0, c1.length(),
|
c1.getBytes(Charset.forName("UTF-8")), 0, c1.length(),
|
||||||
c2.getBytes(), 0, c2.length()
|
c2.getBytes(Charset.forName("UTF-8")), 0, c2.length()
|
||||||
);
|
);
|
||||||
|
|
||||||
//They differ!
|
//They differ!
|
||||||
|
|
Loading…
Reference in New Issue