From d3df810dce5d2813b98ca3f3ebac79f4d4d6cc0e Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Wed, 20 Jul 2016 14:01:17 +0100 Subject: [PATCH] =?UTF-8?q?HADOOP-13387=20users=20always=20get=20told=20of?= =?UTF-8?q?f=20for=20using=20S3=20=E2=80=94even=20when=20not=20using=20it.?= =?UTF-8?q?=20Contributed=20by=20stevel.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/apache/hadoop/fs/s3/S3FileSystem.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java index b6815559b0c..0b8dcf874a7 100644 --- a/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java +++ b/hadoop-tools/hadoop-aws/src/main/java/org/apache/hadoop/fs/s3/S3FileSystem.java @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicBoolean; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -58,7 +59,8 @@ import org.apache.hadoop.util.Progressable; @Deprecated public class S3FileSystem extends FileSystem { - private static boolean hasWarnedDeprecation = false; + private static final AtomicBoolean hasWarnedDeprecation + = new AtomicBoolean(false); private URI uri; @@ -67,23 +69,20 @@ public class S3FileSystem extends FileSystem { private Path workingDir; public S3FileSystem() { - warnDeprecation(); // set store in initialize() } public S3FileSystem(FileSystemStore store) { - warnDeprecation(); this.store = store; } /** * This is to warn the first time in a JVM that an S3FileSystem is created. */ - private static synchronized void warnDeprecation() { - if (!hasWarnedDeprecation) { - System.err.println("S3FileSystem is deprecated and will be removed in " + + private static void warnDeprecation() { + if (!hasWarnedDeprecation.getAndSet(true)) { + LOG.warn("S3FileSystem is deprecated and will be removed in " + "future releases. Use NativeS3FileSystem or S3AFileSystem instead."); - hasWarnedDeprecation = true; } } @@ -105,6 +104,7 @@ public class S3FileSystem extends FileSystem { @Override public void initialize(URI uri, Configuration conf) throws IOException { super.initialize(uri, conf); + warnDeprecation(); if (store == null) { store = createDefaultStore(conf); }