Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-10065

InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant) will close the inputStream

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7.0
    • Component/s: None

      Description

      Now, the implementation of InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant) isĀ 

      @SuppressWarnings("unchecked")
      public static <T> T deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant)
      throws IOException, ClassNotFoundException {
      final ClassLoader old = Thread.currentThread().getContextClassLoader();
      // not using resource try to avoid AutoClosable's close() on the given stream
      try (ObjectInputStream oois = isFailureTolerant
      ? new InstantiationUtil.FailureTolerantObjectInputStream(in, cl)
      : new InstantiationUtil.ClassLoaderObjectInputStream(in, cl)) {
      Thread.currentThread().setContextClassLoader(cl);
      return (T) oois.readObject();
      }
      finally {
      Thread.currentThread().setContextClassLoader(old);
      }
      }
      

      InputStream is closable, so the parameter will be closed after call this method.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                klion26 Congxian Qiu(klion26)
                Reporter:
                klion26 Congxian Qiu(klion26)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: