You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@taverna.apache.org by st...@apache.org on 2015/02/23 11:05:47 UTC
[62/79] incubator-taverna-language git commit: avoid nullPointer when
guessing type from URL
avoid nullPointer when guessing type from URL
Project: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/commit/dc6413a3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/tree/dc6413a3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/diff/dc6413a3
Branch: refs/heads/master
Commit: dc6413a35e445ab124154d4e99277db4273dcc83
Parents: 73af824
Author: Stian Soiland-Reyes <st...@apache.org>
Authored: Sun Feb 22 12:35:12 2015 +0000
Committer: Stian Soiland-Reyes <st...@apache.org>
Committed: Sun Feb 22 12:35:12 2015 +0000
----------------------------------------------------------------------
.../org/apache/taverna/scufl2/api/io/WorkflowBundleIO.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-taverna-language/blob/dc6413a3/taverna-scufl2-api/src/main/java/org/apache/taverna/scufl2/api/io/WorkflowBundleIO.java
----------------------------------------------------------------------
diff --git a/taverna-scufl2-api/src/main/java/org/apache/taverna/scufl2/api/io/WorkflowBundleIO.java b/taverna-scufl2-api/src/main/java/org/apache/taverna/scufl2/api/io/WorkflowBundleIO.java
index d8cb24f..03bf3d1 100644
--- a/taverna-scufl2-api/src/main/java/org/apache/taverna/scufl2/api/io/WorkflowBundleIO.java
+++ b/taverna-scufl2-api/src/main/java/org/apache/taverna/scufl2/api/io/WorkflowBundleIO.java
@@ -89,6 +89,8 @@ import org.apache.taverna.scufl2.api.profiles.Profile;
* </dl>
*/
public class WorkflowBundleIO {
+ private static final int FIRST_BYTES = 1024;
+
private static Logger log = Logger.getLogger(WorkflowBundleIO.class
.getCanonicalName());
@@ -286,7 +288,7 @@ public class WorkflowBundleIO {
public WorkflowBundle readBundle(File bundleFile, String mediaType)
throws ReaderException, IOException {
if (mediaType == null) {
- byte[] firstBytes = new byte[1024];
+ byte[] firstBytes = new byte[FIRST_BYTES];
try (FileInputStream fileIn = new FileInputStream(bundleFile)) {
fileIn.read(firstBytes);
}
@@ -326,7 +328,7 @@ public class WorkflowBundleIO {
public WorkflowBundle readBundle(InputStream inputStream, String mediaType)
throws ReaderException, IOException {
if (mediaType == null) {
- byte[] firstBytes = new byte[1024];
+ byte[] firstBytes = new byte[FIRST_BYTES];
inputStream = new BufferedInputStream(inputStream);
try {
inputStream.mark(firstBytes.length * 2);
@@ -389,7 +391,7 @@ public class WorkflowBundleIO {
contentType = mediaType; // might still be null -> guess
else
for (String ignore : ignoreTypes)
- if (contentType.toLowerCase().startsWith(ignore))
+ if (contentType != null && contentType.toLowerCase().startsWith(ignore))
contentType = mediaType; // might still be null -> guess
// TODO: Pass URL to reader (as baseURI)
return readBundle(url.openStream(), contentType);