Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1250

SerializationUtils::deserialize has unnecessary code and a comment for that

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 3.4
    • Fix Version/s: 3.5
    • Component/s: lang.*
    • Labels:
    • Flags:
      Patch

      Description

      In org.apache.commons.lang3.SerializationUtils L219-L227:

      try {
      // stream closed in the finally
      in = new ObjectInputStream(inputStream);
      @SuppressWarnings("unchecked") // may fail with CCE if serialised form is incorrect
      final T obj = (T) in.readObject();
      return obj;

      } catch (final ClassCastException ex) {
      throw new SerializationException(ex);

      and in the javadoc:

      *
      * <p>
      * If the call site incorrectly types the return value, a {@link ClassCastException} is thrown from the call site.
      * Without Generics in this declaration, the call site must type cast and can cause the same ClassCastException.
      * Note that in both cases, the ClassCastException is in the call site, not in this method.
      * </p>
      *

      There is a conflict. The first catch block and that inlined comment needs to be removed. I'll submit a patch via github soon.

      Blame showed the javadoc and code are written by indiviual person in different years, so that may be the cause.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pascalschumacher Pascal Schumacher
                Reporter:
                glease glease w.
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 5m
                  5m
                  Remaining:
                  Remaining Estimate - 5m
                  5m
                  Logged:
                  Time Spent - Not Specified
                  Not Specified