You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Till Rohrmann (JIRA)" <ji...@apache.org> on 2018/09/28 16:42:00 UTC

[jira] [Resolved] (FLINK-10065) InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant) will close the inputStream

     [ https://issues.apache.org/jira/browse/FLINK-10065?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Till Rohrmann resolved FLINK-10065.
-----------------------------------
       Resolution: Fixed
    Fix Version/s: 1.7.0

Fixed via https://github.com/apache/flink/commit/c17c87147dae4487c873702e0a2cb2f94ee25ec6

> InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant) will close the inputStream
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-10065
>                 URL: https://issues.apache.org/jira/browse/FLINK-10065
>             Project: Flink
>          Issue Type: Bug
>            Reporter: Congxian Qiu
>            Assignee: Congxian Qiu
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.7.0
>
>
> Now, the implementation of InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant) isĀ 
> {code:java}
> @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);
> }
> }
> {code}
> InputStream is closable, so the parameter will be closed after call this method.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)