[ 
https://issues.apache.org/jira/browse/ARTEMIS-5664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18032546#comment-18032546
 ] 

Justin Bertram commented on ARTEMIS-5664:
-----------------------------------------

You're getting a {{NullPointerException}} here because you're use of the API is 
invalid and contra the explicit documentation. Unlike the example you linked, 
your code [creates an *anonymous* 
producer|https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/client/ClientSession.html#createProducer()].
 The corresponding JavaDoc says this:
bq. Address must be specified every time a message is sent
However, when you send the message you _do not_ specify the address (e.g. using 
[this 
method|https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/client/ClientProducer.html#send(org.apache.activemq.artemis.api.core.SimpleString,org.apache.activemq.artemis.api.core.Message)]).

The API could handle this better (e.g by throwing a different exception with a 
clearer message), but the real problem here is the client code. Feel free to 
open a new Jira about the exception that's thrown in this particular invalid 
use-case.

> NullPointerException when using Core 
> -------------------------------------
>
>                 Key: ARTEMIS-5664
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5664
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.31.2, 2.43.0
>         Environment: openjdk version "21.0.8" 2025-07-15
>            Reporter: Mikhail Titov
>            Priority: Major
>         Attachments: NullPointerException_Embedded_Core.tar
>
>
> I have found a NullPointerException bug as a result of fuzz-testing core 
> protocol (using embedded broker) based on [[described 
> example|https://activemq.apache.org/components/artemis/documentation/2.31.2/core.html#a-simple-example-of-using-core|#a-simple-example-of-using-core]]]
> I have created a standalone repro for this bug (attached archive). You can 
> reproduce it by running the following command:
> {code:java}
> java -cp .:jars/* NullPointerBug.java {code}
> If you want to reproduce the bug more than once, you should delete the "data" 
> folder created as a result of the launch.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to