logstash/logstash-logback-encoder — pull request #31 by dmacdonald2013 (2014-05-14 06:17:37+00:00)
Title: Fixed NPE when using logstash appender without any custom fields.

We were getting the following NPE exception when using a logstash syslog appender without any customFields:
RuntimeException in Action for tag [appender] java.lang.NullPointerException
at java.lang.NullPointerException
at	at java.io.StringReader.(StringReader.java:50)
at	at net.logstash.logback.encoder.com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:835)
at	at net.logstash.logback.LogstashFormatter.parseCustomFields(LogstashFormatter.java:188)
at	at net.logstash.logback.LogstashFormatter.setCustomFieldsFromString(LogstashFormatter.java:193)
at	at net.logstash.logback.layout.LogstashLayout.setCustomFields(LogstashLayout.java:36)
at	at net.logstash.logback.appender.LogstashSocketAppender.buildLayout(LogstashSocketAppender.java:30)
at	at ch.qos.logback.core.net.SyslogAppenderBase.start(SyslogAppenderBase.java:64)
at	at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)
at	at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:317)
at	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:196)
at	at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:182)
at	at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:149)
at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:135)
at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:99)
at	at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java
...

I've added a default JSON array to stop the parser complaining. Please see included test cases.