HADOOP-11381. Fix findbugs warnings in hadoop-distcp, hadoop-aws, hadoop-azure, and hadoop-openstack. Contributed by Li Lu.

(cherry picked from commit 2e98ad34ce)

Conflicts:
	hadoop-common-project/hadoop-common/CHANGES.txt
This commit is contained in:
Haohui Mai 2014-12-09 20:45:21 -08:00 committed by cnauroth
parent e71484be18
commit c28449d4b5
2 changed files with 7 additions and 5 deletions

View File

@ -25,6 +25,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -153,7 +154,7 @@ public class NativeAzureFileSystem extends FileSystem {
"Error reading pending rename file contents -- "
+ "maximum file size exceeded");
}
String contents = new String(bytes, 0, l);
String contents = new String(bytes, 0, l, Charset.forName("UTF-8"));
// parse the JSON
ObjectMapper objMapper = new ObjectMapper();
@ -253,7 +254,7 @@ public class NativeAzureFileSystem extends FileSystem {
// Write file.
try {
output = fs.create(path);
output.write(contents.getBytes());
output.write(contents.getBytes(Charset.forName("UTF-8")));
} catch (IOException e) {
throw new IOException("Unable to write RenamePending file for folder rename from "
+ srcKey + " to " + dstKey, e);

View File

@ -18,7 +18,6 @@
package org.apache.hadoop.fs.azure;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.fs.azure.StorageInterface.CloudBlobWrapper;
@ -27,6 +26,8 @@ import com.microsoft.windowsazure.storage.AccessCondition;
import com.microsoft.windowsazure.storage.StorageException;
import com.microsoft.windowsazure.storage.blob.CloudBlob;
import java.util.concurrent.atomic.AtomicInteger;
/**
* An Azure blob lease that automatically renews itself indefinitely
* using a background thread. Use it to synchronize distributed processes,
@ -56,7 +57,7 @@ public class SelfRenewingLease {
private static final Log LOG = LogFactory.getLog(SelfRenewingLease.class);
// Used to allocate thread serial numbers in thread name
private static volatile int threadNumber = 0;
private static AtomicInteger threadNumber = new AtomicInteger(0);
// Time to wait to retry getting the lease in milliseconds
@ -99,7 +100,7 @@ public class SelfRenewingLease {
// A Renewer running should not keep JVM from exiting, so make it a daemon.
renewer.setDaemon(true);
renewer.setName("AzureLeaseRenewer-" + threadNumber++);
renewer.setName("AzureLeaseRenewer-" + threadNumber.getAndIncrement());
renewer.start();
LOG.debug("Acquired lease " + leaseID + " on " + blob.getUri()
+ " managed by thread " + renewer.getName());