hivemq/hivemq-mqtt-client

Possible run-time exception on empty response topic

jyoo980 opened this issue · 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!

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