Skip to content

NullPointerException when closing the TCP socket before the first message is sent #131

Open
@LiamLamb

Description

@LiamLamb

Jenkins and plugins versions report

We're using the TcpSyslogMessageSender to send audit logs in the RFC5424 format to a local rsyslog server.

Our service creates an instance of TcpSyslogMessageSender when it starts and begins emitting events once the start-up procedure has been completely successful.

In cases where our service is shutdown before the first audit event is dispatched, we've noticed that the close method on the TcpSyslogMessageSender can throw a null point exception as the socket hasn't been assigned yet and is indeed null at that stage.

There are other parts of this class that leverage com.cloudbees.syslog.util.IoUtils#closeQuietly, which looks like a suitable solution to this issue.

Keen to get your thoughts on this,
Thanks

What Operating System are you using (both controller, and any agents involved in the problem)?

Error happening on a Windows Feature Experience Pack 1000.19053.1000.0

Reproduction steps

  1. Create a project using com.cloudbees:syslog-java-client:1.1.7
  2. Create an instance of TcpSyslogMessageSender
  3. Invoke the close() method on the TcpSyslogMessageSender instance

Expected Results

Not exception to be thrown

Actual Results

Null pointer exception is thrown

Anything else?

No response

Are you interested in contributing a fix?

Happy to contribute and fix this issue if the solution is adequate enough

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions