eclipse-paho / eclipse-paho/paho.mqtt.java

CommsCallback catches throwables from MqttCallback - hard to use in tests

Open
#619 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

- [x] Bug exists Release Version 1.2.0 ( Master Branch)
- [x] Bug exists in MQTTv3 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)

Any throwably thrown by MqttCallback in the connectionLost callback method is caught in the CommsCallback class. This makes it hard to make a test fail if the connection is lost.

See:
https://github.com/eclipse/paho.mqtt.java/blob/6d7aafddb3a70d7c1eab69e1f9619af8f7ece47c/org.eclipse.paho.client.mqttv3/src/main/java/org/eclipse/paho/client/mqttv3/internal/CommsCallback.java#L297

If this works as expected, do you have any recommendations for handling such a situation?

Contributor guide

Open the contributing guide

Research direction

Start with org.eclipse.paho.client.mqttv3.internal/CommsCallback.java at the connectionLost handling around line 297, then reproduce the behavior with a callback that throws. Check how the callback exception is caught and determine how a test can observe the failure; done means the connection-lost callback behavior is testable without unexpectedly hiding the throwable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.