hivemq-mqtt-client icon indicating copy to clipboard operation
hivemq-mqtt-client copied to clipboard

Possible run-time exception on empty response topic

Open jyoo980 opened this issue 1 year ago • 1 comments

I was looking at some code in RequestResponse.java

and noticed a call to get() here:

.topic(requestPublish.getResponseTopic().get())

will crash with a NoSuchElementException at run time if the response topic is ever an empty Optional. This appears to be a possibility, as getResponseTopic() returns an Optional.ofNullable of a nullable field responseTopic:

private final @Nullable MqttTopicImpl responseTopic;

public @NotNull Optional<MqttTopic> getResponseTopic() {
  return Optional.ofNullable(responseTopic);
}

I am happy to write a patch for this, if desired - thanks!

jyoo980 avatar Dec 11 '23 18:12 jyoo980

Hi, any updates on this? I'm still happy to work with the maintainers on a patch!

jyoo980 avatar Jun 08 '24 02:06 jyoo980