Uploaded image for project: 'Apache Gora'
  1. Apache Gora
  2. GORA-467

Flushing DataOutputStream before calling toByteArray on the underlying ByteArrayOutputStream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 0.7
    • gora-core
    • None

    Description

      In ./gora-core/src/test/java/org/apache/gora/util/TestWritableUtils.java

      ByteArrayOutputStream bos = new ByteArrayOutputStream();
          DataOutput out = new DataOutputStream(bos);
          WritableUtils.writeProperties(out, props);
          
          DataInput in = new DataInputStream(new ByteArrayInputStream(bos.toByteArray()));
      

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

      Attachments

        Activity

          People

            lewismc Lewis John McGibbney
            emopers emopers
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: