Skip to content

Fix NPE for SocketConnection#5976

Open
kwvanderlinde wants to merge 3 commits into
RPTools:developfrom
kwvanderlinde:bugfix/5558-SocketConnection-NPE
Open

Fix NPE for SocketConnection#5976
kwvanderlinde wants to merge 3 commits into
RPTools:developfrom
kwvanderlinde:bugfix/5558-SocketConnection-NPE

Conversation

@kwvanderlinde

@kwvanderlinde kwvanderlinde commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Identify the Bug or Feature request

Fixes #5558

Description of the Change

More clearly distinguishes the "connected" state from other states for SocketConnection. socket, send, and receive are only accessed if socket is first checked to not be null. hostName and port are only accessed if socket is first checked to be null.

Also refactored AbstractConnection a bit:

  • Require the ID to be provided in the constructor (guarantees it is a constant value, and one less method for child classes to implement)
  • Moved the readMessage() and writeMessage() out of AbstractConnection into SocketConnection and WebRTCConnection since each one is specific to one of those.

Possible Drawbacks

Shouldn't be any.

Documentation Notes

N/A

Release Notes

  • Fixed a null pointer exception in socket connections.

This change is Reviewable

@kwvanderlinde kwvanderlinde force-pushed the bugfix/5558-SocketConnection-NPE branch from a7570b4 to d625762 Compare June 17, 2026 19:21
@kwvanderlinde kwvanderlinde moved this from Todo to Awaiting-Review in MapTool 1.19 Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Awaiting-Review

Development

Successfully merging this pull request may close these issues.

NullPointerException: Cannot invoke "java.net.Socket.isClosed()" because "this.socket" is null

1 participant