flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-10065) InstantiationUtil.deserializeObject(InputStream in, ClassLoader cl, boolean isFailureTolerant) will close the inputStream
Date Fri, 28 Sep 2018 16:41:00 GMT

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

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

tillrohrmann closed pull request #6498: [FLINK-10065] InstantiationUtil.deserializeObject(InputStream
in, ClassLoader cl, boolean isFailureTolerant) will close the inputStream
URL: https://github.com/apache/flink/pull/6498
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java b/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
index 2370c7c5437..802bbace060 100644
--- a/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
+++ b/flink-core/src/main/java/org/apache/flink/util/InstantiationUtil.java
@@ -495,9 +495,10 @@ public static void writeObjectToConfig(Object o, Configuration config,
String ke
 
 		final ClassLoader old = Thread.currentThread().getContextClassLoader();
 		// not using resource try to avoid AutoClosable's close() on the given stream
-		try (ObjectInputStream oois = isFailureTolerant
+		try {
+			ObjectInputStream oois = isFailureTolerant
 				? new InstantiationUtil.FailureTolerantObjectInputStream(in, cl)
-				: new InstantiationUtil.ClassLoaderObjectInputStream(in, cl)) {
+				: new InstantiationUtil.ClassLoaderObjectInputStream(in, cl);
 			Thread.currentThread().setContextClassLoader(cl);
 			return (T) oois.readObject();
 		}


 

----------------------------------------------------------------
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:
users@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)

Mime
View raw message