dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40018
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20263: Check for empty or failed stream. Return null on failure
------------------------------------------------------------
revno: 20263
committer: Halvdan Hoem Grelland <halvdanhg@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-21 15:11:42 +0200
message:
Check for empty or failed stream. Return null on failure
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceContentStore.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceContentStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceContentStore.java 2015-09-21 13:01:26 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/fileresource/DefaultFileResourceContentStore.java 2015-09-21 13:11:42 +0000
@@ -214,7 +214,7 @@
return null;
}
- return new ByteSource()
+ ByteSource byteSource = new ByteSource()
{
@Override
public InputStream openStream()
@@ -229,6 +229,19 @@
}
}
};
+
+ boolean isEmptyOrFailed;
+
+ try
+ {
+ isEmptyOrFailed = byteSource.isEmpty();
+ }
+ catch ( IOException e )
+ {
+ isEmptyOrFailed = true;
+ }
+
+ return isEmptyOrFailed ? null : byteSource;
}
public String saveFileResourceContent( String key, ByteSource content, long size, String contentMd5 )