gora-dev 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] (GORA-467) Flushing DataOutputStream before calling toByteArray on the underlying ByteArrayOutputStream
Date Thu, 04 Feb 2016 21:47:39 GMT

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

ASF GitHub Bot commented on GORA-467:
-------------------------------------

Github user lewismc commented on the pull request:

    https://github.com/apache/gora/pull/55#issuecomment-180065650
  
    Hi @emopers I just undertook a quick scan of the codebase for ByteArrayOutputStream, I
found the following instances. Can you please check these out as well?
    ```
    ./gora-accumulo/src/main/java/org/apache/gora/accumulo/encoders/BinaryEncoder.java
    ./gora-accumulo/src/main/java/org/apache/gora/accumulo/store/AccumuloStore.java
    ./gora-accumulo/src/main/java/org/apache/gora/accumulo/util/FixedByteArrayOutputStream.java
    ./gora-accumulo/src/test/java/org/apache/gora/accumulo/store/PartitionTest.java
    ./gora-cassandra/src/main/java/org/apache/gora/cassandra/serializers/AvroSerializerUtil.java
    ./gora-core/src/main/java/org/apache/gora/util/AvroUtils.java
    ./gora-core/src/main/java/org/apache/gora/util/IOUtils.java
    ./gora-core/src/test/java/org/apache/gora/util/TestWritableUtils.java
    ./gora-hbase/src/main/java/org/apache/gora/hbase/util/HBaseByteInterface.java
    ```


> Flushing DataOutputStream before calling toByteArray on the underlying ByteArrayOutputStream
> --------------------------------------------------------------------------------------------
>
>                 Key: GORA-467
>                 URL: https://issues.apache.org/jira/browse/GORA-467
>             Project: Apache Gora
>          Issue Type: Bug
>          Components: gora-core
>            Reporter: emopers
>            Priority: Minor
>
> In ./gora-core/src/test/java/org/apache/gora/util/TestWritableUtils.java
> {code}
> ByteArrayOutputStream bos = new ByteArrayOutputStream();
>     DataOutput out = new DataOutputStream(bos);
>     WritableUtils.writeProperties(out, props);
>     
>     DataInput in = new DataInputStream(new ByteArrayInputStream(bos.toByteArray()));
> {code}
> When a DataOutputStream instance wraps an underlying ByteArrayOutputStream instance,
> it is recommended to flush or close the DataOutputStream before invoking the underlying
instances's toByteArray(). Also, it is a good practice to call flush/close explicitly as mentioned
for example at http://stackoverflow.com/questions/2984538/how-to-use-bytearrayoutputstream-and-dataoutputstream-simultaneously-java.
> The patch adds a flush method before calling toByteArray().



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message