Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-3253

UploadedFilePart.getBytes() method does not write the exact ranges of bytes read into the byte[] buffer

    Details

      Description

      The UploadedFilePart class appears in several demo portlets. The getBytes() method has a loop that looks like the following:

      UploadedFilePart.java
      	@Override
      	public byte[] getBytes() throws IOException {
      
      		ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
      		InputStream inputStream = getWrapped().getInputStream();
      		byte[] byteBuffer = new byte[1024];
      		int bytesRead = inputStream.read(byteBuffer);
      
      		while (bytesRead != -1) {
      			byteArrayOutputStream.write(byteBuffer);
      			bytesRead = inputStream.read(byteBuffer);
      		}
      
      		byteArrayOutputStream.flush();
      
      		return byteArrayOutputStream.toByteArray();
      	}
      

      The problem is that the exact range of bytes read (0 to bytesRead) into the byte[] byteBuffer is not written to the byteArrayOutputStream.

        Attachments

          Activity

            People

            • Assignee:
              neil.griffin Neil Griffin
              Reporter:
              neil.griffin Neil Griffin
              Participants of an Issue:
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                bridge-impl-4.1.1
                showcase-3.0.2