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 969ca3a784..ce0c3fe398 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); } } 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 2cde3e3ecc..d9a0009068 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 void testSerializationKeyIsEmpty() { 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();