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

no auth causes npe #50

Open
kortemik opened this issue May 3, 2024 · 3 comments · Fixed by #61
Open

no auth causes npe #50

kortemik opened this issue May 3, 2024 · 3 comments · Fixed by #61
Assignees
Labels
bug Something isn't working

Comments

@kortemik
Copy link
Member

kortemik commented May 3, 2024

Describe the bug
when authentication is not set, one will get npe out of
sdElement.addSDParam("subject", subject);

03.05.2024 14:06:09.529 [ERROR] [com.teragrep.lsh_01.RelpConversion] [http-input-handler-executor[T#1]] Unexpected error when sending a message: <Cannot invoke "String.length()" because "paramValue" is null> java.lang.NullPointerException: Cannot invoke "String.length()" because "paramValue" is null
        at com.teragrep.rlo_14.SyslogMessage.getEscapedParamValue(SyslogMessage.java:273)
        at com.teragrep.rlo_14.SyslogMessage.writeSDElements(SyslogMessage.java:265)
        at com.teragrep.rlo_14.SyslogMessage.toRfc5424SyslogMessage(SyslogMessage.java:248)
        at com.teragrep.rlo_14.SyslogMessage.toRfc5424SyslogMessage(SyslogMessage.java:207)
        at com.teragrep.lsh_01.RelpConversion.sendMessage(RelpConversion.java:191)
        at com.teragrep.lsh_01.RelpConversion.onNewMessage(RelpConversion.java:81)
        at com.teragrep.lsh_01.MessageProcessor.processMessage(MessageProcessor.java:139)
        at com.teragrep.lsh_01.MessageProcessor.run(MessageProcessor.java:121)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:840)

same goes for

        for (Map.Entry<String, String> header : headers.entrySet()) {
            headerSDElement.addSDParam(new SDParam(header.getKey(), header.getValue()));
        }

Expected behavior
no npe, empty element.

How to reproduce
send message without authentication set

Screenshots

Software version
3.1.1

Desktop (please complete the following information if relevant):

  • OS:
  • Browser:
  • Version:

Additional context

@kortemik kortemik added the bug Something isn't working label May 3, 2024
@kortemik
Copy link
Member Author

kortemik commented May 6, 2024

lsh_01-test-plan.zip

@kortemik
Copy link
Member Author

kortemik commented May 8, 2024

can the sdElement.addSDParam("subject", subject); still cause it?

@51-code
Copy link

51-code commented May 13, 2024

sdElement.addSDParam("subject", subject); can't cause an NPE.
The Subject is created in MessageProcessor, either as an empty string (SubjectAnonymous) or an actual string (SubjectImpl). SubjectImpl is only created through BasicAuthentication for now, and there, the asSubject() method checks for null values and throws an IllegalArgumentException if that is the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants