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

GelfMessage should fail on host = "", shortmessage="" #82

Closed
ipavkovic opened this issue Feb 21, 2022 · 4 comments
Closed

GelfMessage should fail on host = "", shortmessage="" #82

ipavkovic opened this issue Feb 21, 2022 · 4 comments
Milestone

Comments

@ipavkovic
Copy link

ipavkovic commented Feb 21, 2022

Describe the bug
We have a logging with a short message "" (coming from the root cause NullPointerException)

GelfMessage checks for null but not empty message. Our Graylog server silently skips a message with short_message = "" even if full message is filled properly

        this.host = Objects.requireNonNull(host, "host must not be null");
        this.shortMessage = Objects.requireNonNull(shortMessage, "shortMessage must not be null");

should be changed to something like

        this.host = requireNotEmpty(host, "host must not be empty");
        this.shortMessage = requireNotEmpty(shortMessage, "shortMessage must not be empty");
[...]
       private static void requireNotEmpty(String value, String message) {
         if (value == null || value.trim().isEmpty()) {
           throw new IllegalStateException(message);
         }
       }

insert test code here


@osiegmar
Copy link
Owner

Related: Graylog2/graylog2-server#5171

@osiegmar
Copy link
Owner

Which version of graylog-server do you use?

@ipavkovic
Copy link
Author

Graylog2/graylog2-server#5171

Graylog 3.3.16+f766a24

@osiegmar
Copy link
Owner

According to GelfCodec.java, Graylog requires a short_message that "is not blank" (by using Apache Commons Lang3 StringUtils). The definition of blank by org.apache.commons.lang3.StringUtils#isBlank:

Checks if a CharSequence is empty (""), null or whitespace only. Whitespace is defined by Character.isWhitespace(char).

So this will be changed in the next release of this library.

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

2 participants