Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

NullPointerException when log4j2 is stoping the GELF appender #111

Closed
badreddine16 opened this issue Mar 14, 2017 · 2 comments
Closed

NullPointerException when log4j2 is stoping the GELF appender #111

badreddine16 opened this issue Mar 14, 2017 · 2 comments
Labels
type: bug A general bug

Comments

@badreddine16
Copy link

badreddine16 commented Mar 14, 2017

logstash-gelf version : 1.11.0

SImple Log4J Appender's Configuration :

<Gelf name="gelf" host="ssl:hostname" port="12201" version="1.1">
	<ThresholdFilter level="ERROR" onMatch="ACCEPT" onMismatch="DENY" />
	<Field name="timestamp" pattern="%d{dd MMM yyyy HH:mm:ss,SSS}" />
	<Field name="level" pattern="%level" />
	<Field name="simpleClassName" pattern="%C{1}" />
	<Field name="className" pattern="%C" />
	<Field name="server" pattern="%host" />
	<Field name="server.simple" pattern="%host{simple}" />
	<Field name="server.fqdn" pattern="%host{fqdn}" />
	<Field name="server.addr" pattern="%host{address}" />
</Gelf>

A NullPointerException happens when Log4j close the SSL connection (because he is is trying to stop the appender), but the connection is not established yet.

Stacktrace :

2017-03-14 16:46:25 ERROR SpringApplication:826 - Application startup failed
java.lang.NullPointerException
	at biz.paluch.logging.gelf.intern.sender.GelfTCPSSLSender.closeSocketChannel(GelfTCPSSLSender.java:268) ~[logstash-gelf-1.11.0.jar:?]
	at biz.paluch.logging.gelf.intern.sender.GelfTCPSSLSender.close(GelfTCPSSLSender.java:257) ~[logstash-gelf-1.11.0.jar:?]
	at biz.paluch.logging.gelf.intern.Closer.close(Closer.java:23) ~[logstash-gelf-1.11.0.jar:?]
	at biz.paluch.logging.gelf.log4j2.GelfLogAppender.stop(GelfLogAppender.java:359) ~[logstash-gelf-1.11.0.jar:?]
	at org.apache.logging.log4j.core.config.AbstractConfiguration.stop(AbstractConfiguration.java:272) ~[log4j-core-2.4.1.jar:2.4.1]
	at org.apache.logging.log4j.core.LoggerContext.setConfiguration(LoggerContext.java:451) ~[log4j-core-2.4.1.jar:2.4.1]
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:520) ~[log4j-core-2.4.1.jar:2.4.1]
	at org.apache.logging.log4j.core.LoggerContext.reconfigure(LoggerContext.java:536) ~[log4j-core-2.4.1.jar:2.4.1]
	at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.reinitialize(Log4J2LoggingSystem.java:184) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:64) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:49) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.log4j2.Log4J2LoggingSystem.initialize(Log4J2LoggingSystem.java:137) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:261) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:232) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:199) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:176) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:163) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:136) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:119) ~[spring-context-4.2.3.RELEASE.jar:4.2.3.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:111) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:65) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.doRun(SpringApplication.java:315) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:295) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1112) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1101) [spring-boot-1.3.0.RELEASE.jar:1.3.0.RELEASE]
	at xxx.xxx.xxx.Application.main(Application.java:34) [classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_112]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_112]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_112]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_112]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.3.0.RELEASE.jar:1.3.0.RELEASE]
@badreddine16 badreddine16 changed the title NullPointerException when closing SSL connection NullPointerException when log4j2 is stoping the GELF appender Mar 14, 2017
@mp911de mp911de added the type: bug A general bug label Mar 15, 2017
@mp911de
Copy link
Owner

mp911de commented Mar 15, 2017

Thanks a lot for your pull-request. If you require an immediate fix, please build the library yourself with your fix applied until the next release of logstash-gelf is available.

@mp911de mp911de added this to the logstash-gelf 1.11.1 milestone Mar 15, 2017
mp911de pushed a commit that referenced this issue Mar 15, 2017
…gine #111

Do not interact with SSLEngine if SSLEngine is not available. This can happen if the sender is closed without establishing a connection prior closing.

Original pull request: #112.
@mp911de
Copy link
Owner

mp911de commented Mar 15, 2017

Fixed via 0125d27.

@mp911de mp911de closed this as completed Mar 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants