Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException if only amqp is defined #126

Open
medoctron opened this issue Nov 25, 2018 · 0 comments
Open

NullPointerException if only amqp is defined #126

medoctron opened this issue Nov 25, 2018 · 0 comments

Comments

@medoctron
Copy link

If you configure for example the following:

handlers=org.graylog2.logging.GelfHandler
.handlers=org.graylog2.logging.GelfHandler
.level = ALL

org.graylog2.logging.GelfHandler.level = ALL

org.graylog2.logging.GelfHandler.amqpURI=amqp://just.a.test
org.graylog2.logging.GelfHandler.amqpExchangeName=messages
org.graylog2.logging.GelfHandler.amqpRoutingKey=gelfudp
org.graylog2.logging.GelfHandler.amqpMaxRetries=5

org.graylog2.logging.GelfHandler.extractStacktrace = true

then the code will throw a NullPointerException in org.graylog2.logging.GelfHandler.publish(LogRecord) at location

if (graylogHost.startsWith("tcp:")) {

graylogHost is null in the described case.

Here's a test case to reproduce the bug, using the configuration from above as file "logging-only-amqp-test.properties":

@Test
public void testConfigureOnlyAmqpLogging() throws SecurityException, IOException {
	// In versions <= 1.1.16 there's a bug that throws a NullPointerException if you
	// only configure amqp but leave graylogHost empty
	InputStream is = GelfHandlerTest.class.getResourceAsStream("logging-only-amqp-test.properties");
	LogManager.getLogManager().readConfiguration(is);

	GelfHandler gelfHandler = new GelfHandler();
	gelfHandler.publish(new LogRecord(Level.INFO, "testMessage"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant