I ran into the following NullPointerException:
16:40:01,170 |-ERROR in com.eclecticlogic.whisper.logback.WhisperAppender[whisper] - Appender [whisper] failed to append. java.lang.NullPointerException
at java.lang.NullPointerException
at at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:768)
at at com.eclecticlogic.whisper.core.WhisperManager.log(WhisperManager.java:82)
at at com.eclecticlogic.whisper.logback.WhisperAppender.append(WhisperAppender.java:90)
at at com.eclecticlogic.whisper.logback.WhisperAppender.append(WhisperAppender.java:37)
I back tracked that to the original error message (logged by the File Appender):
14-01 16:40:01 [ajp-bio-8812-exec-12] com.hcs.data.dao.jdbc.util.JDBCDAOUtil ERROR null
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'webtl_orc_dev_1_4_3.procedures' doesn't exist
Which came from this code in my application:
} catch (SQLException ex) {
log.log(Level.SEVERE, null, ex);
}
While you can make a good argument that it is poor form to provide a null message, it does not cause problems for Logback's File Appender or SMTP Appender. Even if the WhisperAppender didn't throw an NPE, it would cause problems for the digest if I have multiple different "errors" being logged with a null message.
So, my question/bug/concern is two fold:
- Is there a better way to handle this then throwing an NPE when the message is null?
- Is there a better way to recognize duplicate messages that have null messages?
I can fix my code, of course, but it is easy enough for another null message to creep back in at a later date (old programming habits can die hard), which could cause us to miss important error messages.
This may or may not be a bug, but I couldn't find anywhere else to raise the question, so my apologies if this was the wrong spot.