A constructor can never return null, but it can throw an exception. So don't bother to test whether the FileInputStream is null; instead, catch a FileNotFoundException.

This commit is contained in:
jeb228 2011-02-07 15:39:34 +00:00
parent 3ad00d0ace
commit ec5283795f

View file

@ -4,6 +4,7 @@ package edu.cornell.mannlib.vitro.webapp.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@ -573,14 +574,6 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
String path = context.getRealPath(FEDORA_PROPERTIES);
try{
InputStream in = new FileInputStream(new File( path ));
if( in == null ){
log.error("No fedora.properties file found,"+
"it should be located at " + path);
status.append("<h1>Fedora configuration failed.</h1>\n");
status.append("<p>No fedora.properties file found,"+
"it should be located at " + path + "</p>\n");
configured = false;
} else {
props.load( in );
fedoraUrl = props.getProperty("fedoraUrl");
adminUser = props.getProperty("adminUser");
@ -619,7 +612,14 @@ public class FedoraDatastreamController extends VitroHttpServlet implements Cons
} else {
configured = true;
}
}
}catch(FileNotFoundException e) {
log.error("No fedora.properties file found,"+
"it should be located at " + path);
status.append("<h1>Fedora configuration failed.</h1>\n");
status.append("<p>No fedora.properties file found,"+
"it should be located at " + path + "</p>\n");
configured = false;
return;
}catch(Exception ex){
status.append("<p>Fedora configuration failed.</p>\n");
status.append("<p>Exception while loading" + path + "</p>\n");