Skip to content

Commit

Permalink
prevent NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
darkv committed Dec 12, 2012
1 parent 4f493e3 commit 2923432
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static String getProperty(final String key)
logger.warn("Unable to load properties file.", e);
}
}
return props.getProperty(key);
return props != null ? props.getProperty(key) : null;
}


Expand All @@ -109,7 +109,7 @@ public static String getProperty(final String key, final String defaultValue)
logger.warn("Unable to load properties file.", e);
}
}
return props.getProperty(key, defaultValue);
return props != null ? props.getProperty(key, defaultValue) : defaultValue;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public void objectStoreWasAdded(NSNotification aNotification) {
log.debug("Shared EO loading complete: no objects loaded.");
}
} catch (Exception e) {
log.error("Exception occurred with model: " + currentModel.name() + "\n" + e + ERXUtilities.stackTrace());
log.error("Exception occurred with model: " + (currentModel != null ? currentModel.name() : "<null>" ) + "\n" + e + ERXUtilities.stackTrace());
// no matter what happens, un-register for notifications.
NSNotificationCenter.defaultCenter().removeObserver(this, EOAdaptorContext.AdaptorContextBeginTransactionNotification, null);
if (_didChangeDebugSetting) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ private void getRandomGUID(boolean secure) {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
System.out.println("Error: " + e);
valueBeforeMD5 = "";
valueAfterMD5 = "";
return;
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ public Field valueToField(Document doc, Object value) {
} else {
field = null;
}
field.setValue(stringValue);
if (field != null) {
field.setValue(stringValue);
}
return field;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ public synchronized void messageReceived(IInstantMessenger instantMessenger, Str
if (responseMessage != null) {
responseMessage = responseMessage.trim();
}
if (responseMessage.length() > 0) {
if (responseMessage != null && responseMessage.length() > 0) {
if (log.isInfoEnabled()) {
log.info("Sending message to '" + buddyName + "': " + responseMessage);
}
Expand Down

0 comments on commit 2923432

Please sign in to comment.