Repository: flink Updated Branches: refs/heads/release-1.1 9f7269808 -> fe464b424
[FLINK-4709] [core] Fix resource leak in InputStreamFSInputWrapper This closes #2581 Project: http://git-wip-us.apache.org/repos/asf/flink/repo Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/fe464b42 Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/fe464b42 Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/fe464b42 Branch: refs/heads/release-1.1 Commit: fe464b42483399a5dee5116699f600c551c37db9 Parents: 9f72698 Author: Holger Frydrych <[email protected]> Authored: Mon Oct 3 14:34:19 2016 +0200 Committer: Stephan Ewen <[email protected]> Committed: Sun Oct 16 19:11:11 2016 +0200 ---------------------------------------------------------------------- .../common/io/InputStreamFSInputWrapper.java | 5 +++ .../io/InputStreamFSInputWrapperTest.java | 38 ++++++++++++++++++++ 2 files changed, 43 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink/blob/fe464b42/flink-core/src/main/java/org/apache/flink/api/common/io/InputStreamFSInputWrapper.java ---------------------------------------------------------------------- diff --git a/flink-core/src/main/java/org/apache/flink/api/common/io/InputStreamFSInputWrapper.java b/flink-core/src/main/java/org/apache/flink/api/common/io/InputStreamFSInputWrapper.java index cfd94bc..f7db680 100644 --- a/flink-core/src/main/java/org/apache/flink/api/common/io/InputStreamFSInputWrapper.java +++ b/flink-core/src/main/java/org/apache/flink/api/common/io/InputStreamFSInputWrapper.java @@ -42,6 +42,11 @@ public class InputStreamFSInputWrapper extends FSDataInputStream { } @Override + public void close() throws IOException { + this.inStream.close(); + } + + @Override public void seek(long desired) throws IOException { if (desired < this.pos) { throw new IllegalArgumentException("Wrapped InputStream: cannot search backwards."); http://git-wip-us.apache.org/repos/asf/flink/blob/fe464b42/flink-core/src/test/java/org/apache/flink/api/common/io/InputStreamFSInputWrapperTest.java ---------------------------------------------------------------------- diff --git a/flink-core/src/test/java/org/apache/flink/api/common/io/InputStreamFSInputWrapperTest.java b/flink-core/src/test/java/org/apache/flink/api/common/io/InputStreamFSInputWrapperTest.java new file mode 100644 index 0000000..8fcd231 --- /dev/null +++ b/flink-core/src/test/java/org/apache/flink/api/common/io/InputStreamFSInputWrapperTest.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.api.common.io; + +import java.io.InputStream; + +import org.junit.Test; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; + +public class InputStreamFSInputWrapperTest { + + @Test + public void testClose() throws Exception { + InputStream mockedInputStream = mock(InputStream.class); + InputStreamFSInputWrapper wrapper = new InputStreamFSInputWrapper(mockedInputStream); + wrapper.close(); + verify(mockedInputStream).close(); + } + +}
