Uploaded image for project: 'MRUnit'
  1. MRUnit
  2. MRUNIT-193

Serialization.copy throws NPE instead of ISE (missing serilization impl) for Hadoop 2.x

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Trivial
    • Resolution: Fixed
    • 1.0.0
    • 1.1.0
    • None

    Description

      This may be the result of a refactoring.
      The current code attempts to catch a NPE with the intent to detect a missing serialization implementation.

      However this behavior differs between Hadoop 1.x and 2.x
      Hadoop 1.x will NPE in the first try/catch block, while 2.x will in the second.

          try {
            serializer = (Serializer<Object>) serializationFactory
                .getSerializer(clazz);
            deserializer = (Deserializer<Object>) serializationFactory
                .getDeserializer(clazz);
          } catch (NullPointerException e) {
            throw new IllegalStateException(
                "No applicable class implementing Serialization in conf at io.serializations for "
                    + orig.getClass(), e);
          }
          try {
            final DataOutputBuffer outputBuffer = new DataOutputBuffer();
            serializer.open(outputBuffer);
            serializer.serialize(orig);
            final DataInputBuffer inputBuffer = new DataInputBuffer();
            inputBuffer.reset(outputBuffer.getData(), outputBuffer.getLength());
            deserializer.open(inputBuffer);
            return (T) deserializer.deserialize(copy);
          } catch (final IOException e) {
            throw new RuntimeException(e);
          }
      

      Hadoop 1.x

        public <T> Serializer<T> getSerializer(Class<T> c) {
          return getSerialization(c).getSerializer(c);
        }
      

      Hadoop 2.x

        public <T> Serializer<T> getSerializer(Class<T> c) {
          Serialization<T> serializer = getSerialization(c);
          if (serializer != null) {
            return serializer.getSerializer(c);
          }
          return null;
        }
      

      Attachments

        Activity

          People

            clehene Cosmin Lehene
            clehene Cosmin Lehene
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified