Handle empty files in content

This commit is contained in:
René Pfeuffer
2018-08-24 08:52:19 +02:00
parent 4699166f87
commit 9775817269
2 changed files with 14 additions and 12 deletions

View File

@@ -142,7 +142,9 @@ public class ContentResource {
try {
byte[] buffer = new byte[HEAD_BUFFER_SIZE];
int length = stream.read(buffer);
if (length < buffer.length) {
if (length < 0) { // empty file
return new byte[]{};
} else if (length < buffer.length) {
return Arrays.copyOf(buffer, length);
} else {
return buffer;