hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From templ...@apache.org
Subject hadoop git commit: HADOOP-14459. SerializationFactory shouldn't throw a NullPointerException if the serializations list is not defined (Contributed by Nandor Kollar via Daniel Templeton)
Date Wed, 04 Oct 2017 13:21:38 GMT
Repository: hadoop
Updated Branches:
  refs/heads/branch-3.0 7ba174791 -> 280b1fe1b


HADOOP-14459. SerializationFactory shouldn't throw a NullPointerException if the serializations
list is not defined
(Contributed by Nandor Kollar via Daniel Templeton)

(cherry picked from commit 20e9ce3ab33599d2ac6859a8319e1ce0bf0a4363)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/280b1fe1
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/280b1fe1
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/280b1fe1

Branch: refs/heads/branch-3.0
Commit: 280b1fe1b4b2580d610bedde3cb765a2bbd508ac
Parents: 7ba1747
Author: Daniel Templeton <templedf@apache.org>
Authored: Wed Oct 4 15:04:02 2017 +0200
Committer: Daniel Templeton <templedf@apache.org>
Committed: Wed Oct 4 15:11:03 2017 +0200

----------------------------------------------------------------------
 .../io/serializer/SerializationFactory.java       | 18 ++++++------------
 .../io/serializer/TestSerializationFactory.java   | 13 +++++++++++++
 2 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/280b1fe1/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/serializer/SerializationFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/serializer/SerializationFactory.java
b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/serializer/SerializationFactory.java
index 969ca3a..ce0c3fe 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/serializer/SerializationFactory.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/serializer/SerializationFactory.java
@@ -55,18 +55,12 @@ public class SerializationFactory extends Configured {
    */
   public SerializationFactory(Configuration conf) {
     super(conf);
-    if (conf.get(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY).equals("")) {
-      LOG.warn("Serialization for various data types may not be available. Please configure
"
-          + CommonConfigurationKeys.IO_SERIALIZATIONS_KEY
-          + " properly to have serialization support (it is currently not set).");
-    } else {
-      for (String serializerName : conf.getTrimmedStrings(
-          CommonConfigurationKeys.IO_SERIALIZATIONS_KEY, new String[] {
-              WritableSerialization.class.getName(),
-              AvroSpecificSerialization.class.getName(),
-              AvroReflectSerialization.class.getName() })) {
-        add(conf, serializerName);
-      }
+    for (String serializerName : conf.getTrimmedStrings(
+            CommonConfigurationKeys.IO_SERIALIZATIONS_KEY,
+            new String[]{WritableSerialization.class.getName(),
+                    AvroSpecificSerialization.class.getName(),
+                    AvroReflectSerialization.class.getName()})) {
+      add(conf, serializerName);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/hadoop/blob/280b1fe1/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java
b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java
index 2cde3e3..d9a0009 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/serializer/TestSerializationFactory.java
@@ -51,6 +51,19 @@ public class TestSerializationFactory {
     SerializationFactory factory = new SerializationFactory(conf);
   }
 
+  /**
+   * Test the case when {@code IO_SERIALIZATIONS_KEY}
+   * is not set at all, because something unset this key.
+   * This shouldn't result in any error, the defaults present
+   * in construction should be used in this case.
+   */
+  @Test
+  public void testSerializationKeyIsUnset() {
+    Configuration conf = new Configuration();
+    conf.unset(CommonConfigurationKeys.IO_SERIALIZATIONS_KEY);
+    SerializationFactory factory = new SerializationFactory(conf);
+  }
+
   @Test
   public void testSerializationKeyIsInvalid() {
     Configuration conf = new Configuration();


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message