You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/05/16 22:20:12 UTC
[jira] [Commented] (FLINK-3782) ByteArrayOutputStream and
ObjectOutputStream should close
[ https://issues.apache.org/jira/browse/FLINK-3782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15285538#comment-15285538 ]
ASF GitHub Bot commented on FLINK-3782:
---------------------------------------
GitHub user rekhajoshm opened a pull request:
https://github.com/apache/flink/pull/1995
[FLINK-3782] ByteArrayOutputStream and ObjectOutputStream should close
[FLINK-3782] ByteArrayOutputStream and ObjectOutputStream should close
The ByteArrayOutputStream close method is useless and has no impact, so is usually never called.However I am using try with resources for both to take care of closing closeable resources automatically.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rekhajoshm/flink FLINK-3782
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/flink/pull/1995.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1995
----
commit 2fec41be0f1ef8f1b9f707d0085d6f9fca8101bb
Author: Joshi <re...@gmail.com>
Date: 2016-05-16T22:18:42Z
[FLINK-3782] ByteArrayOutputStream and ObjectOutputStream should close
----
> ByteArrayOutputStream and ObjectOutputStream should close
> ---------------------------------------------------------
>
> Key: FLINK-3782
> URL: https://issues.apache.org/jira/browse/FLINK-3782
> Project: Flink
> Issue Type: Test
> Components: Java API
> Affects Versions: 1.0.1
> Reporter: Chenguang He
> Priority: Minor
> Labels: test
>
> ByteArrayOutputStream and ObjectOutputStream should close
> @Test
> public void testSerializability() {
> try {
> Collection<ElementType> inputCollection = new ArrayList<ElementType>();
> ElementType element1 = new ElementType(1);
> ElementType element2 = new ElementType(2);
> ElementType element3 = new ElementType(3);
> inputCollection.add(element1);
> inputCollection.add(element2);
> inputCollection.add(element3);
>
> @SuppressWarnings("unchecked")
> TypeInformation<ElementType> info = (TypeInformation<ElementType>) TypeExtractor.createTypeInfo(ElementType.class);
>
> CollectionInputFormat<ElementType> inputFormat = new CollectionInputFormat<ElementType>(inputCollection,
> info.createSerializer(new ExecutionConfig()));
> ByteArrayOutputStream buffer = new ByteArrayOutputStream();// <----open in here
> ObjectOutputStream out = new ObjectOutputStream(buffer);// <----open in here
> out.writeObject(inputFormat);
> ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); // <----open in here
> Object serializationResult = in.readObject();
> assertNotNull(serializationResult);
> assertTrue(serializationResult instanceof CollectionInputFormat<?>);
> @SuppressWarnings("unchecked")
> CollectionInputFormat<ElementType> result = (CollectionInputFormat<ElementType>) serializationResult;
> GenericInputSplit inputSplit = new GenericInputSplit(0, 1);
> inputFormat.open(inputSplit);
> result.open(inputSplit);
> while(!inputFormat.reachedEnd() && !result.reachedEnd()){
> ElementType expectedElement = inputFormat.nextRecord(null);
> ElementType actualElement = result.nextRecord(null);
> assertEquals(expectedElement, actualElement);
> }
> }
> catch(Exception e) {
> e.printStackTrace();
> fail(e.toString());
> }
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)