[ 
https://issues.apache.org/jira/browse/FLINK-10065?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16611683#comment-16611683
 ] 

ASF GitHub Bot commented on FLINK-10065:
----------------------------------------

klion26 commented on issue #6498: [FLINK-10065] 
InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean 
isFailureTolerant) will close the inputStream
URL: https://github.com/apache/flink/pull/6498#issuecomment-420534659
 
 
   Hi, @StephanEwen @tzulitai @tillrohrmann Could you help to review this pr 
please?
   
   I encountered this problem while refactor snapshot/restore in my owner 
branch, in the restore function, I opened the file and called 
`InstantiationUtil#deserializeObject` from the previous opened InputStream, 
then the InputStream will closed by `InstantiationUtil#deserializeObject`.
   
   I think others may encounter this problem too, so please help to review this 
pr, thank you

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> 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
>
> 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)

Reply via email to