NullPointers in property handling

This commit is contained in:
Peter Hormanns 2012-07-26 11:37:59 +00:00
parent e30d26fd77
commit dec7a70e42
2 changed files with 11 additions and 3 deletions

View File

@ -117,6 +117,7 @@ public class CASTicket {
}
private String readFiledGrantingTicket() throws JSCliException {
String filedTicket = null;
String userHome = System.getProperty("user.home");
String ticketFileName = userHome + "/.hsadmin.tgt";
File file = new File(ticketFileName);
@ -124,12 +125,15 @@ public class CASTicket {
Properties properties = new Properties();
try {
properties.load(new FileReader(file));
return properties.getProperty(user);
filedTicket = properties.getProperty(user);
} catch (IOException e) {
throw new JSCliException(e);
}
}
return null;
if (filedTicket == null) {
filedTicket = getGrantingTicket();
}
return filedTicket;
}
private void writeFiledGrantingTicket(String ticket) throws JSCliException {

View File

@ -43,7 +43,11 @@ public class Config {
}
public String getProperty(String propertyName) {
return props.getProperty(propertyName).trim();
String property = props.getProperty(propertyName);
if (property == null) {
return null;
}
return property.trim();
}
public String getProperty(String propertyName, String defaultValue) {