You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Adel Boutros <Ad...@live.com> on 2017/01/13 13:41:03 UTC

[Qpid JMS 0.11.1] Nullpointer exception when providing an empty string to the ConnectionFactory

Hello,


While playing around with the JMS API, we noticed that if an empty string is passed to the JmsConnectionFactory constructor, it will throw back a NullPointerException because it tries to access the ".toString" of a NULL URL (See createURI).


Do you agree that it would be better to throw an exception which clearly says an empty String URL is forbidden? If yes, I will add a jira issue for it.


public static void main(String[] args) {
    new JmsConnectionFactory("");
}


Output

------------

Exception in thread "main" java.lang.NullPointerException
at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:115)
at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:111)


Regards,

Adel

Re: [Qpid JMS 0.11.1] Nullpointer exception when providing an empty string to the ConnectionFactory

Posted by Timothy Bish <ta...@gmail.com>.
On 01/13/2017 10:08 AM, Adel Boutros wrote:
> Hello Tim,
>
>
> I took a look on the master brunch of the github repo and indeed it seems to be fixed.
>
>
> Regards,
>
> Adel

I made some additional changes to make the error reporting more consistent.

>
> ________________________________
> From: Timothy Bish <ta...@gmail.com>
> Sent: Friday, January 13, 2017 3:30:59 PM
> To: users@qpid.apache.org
> Subject: Re: [Qpid JMS 0.11.1] Nullpointer exception when providing an empty string to the ConnectionFactory
>
> On 01/13/2017 08:41 AM, Adel Boutros wrote:
>> Hello,
>>
>>
>> While playing around with the JMS API, we noticed that if an empty string is passed to the JmsConnectionFactory constructor, it will throw back a NullPointerException because it tries to access the ".toString" of a NULL URL (See createURI).
>>
>>
>> Do you agree that it would be better to throw an exception which clearly says an empty String URL is forbidden? If yes, I will add a jira issue for it.
>>
>>
>> public static void main(String[] args) {
>>       new JmsConnectionFactory("");
>> }
>>
>>
>> Output
>>
>> ------------
>>
>> Exception in thread "main" java.lang.NullPointerException
>> at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:115)
>> at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:111)
>>
>>
>> Regards,
>>
>> Adel
>>
> I will take a look at the code again, some things were fixed recently in
> QPIDJMS-245 but there's probably a few more defensive checks needed to
> keep people from hitting this.
>
>
> --
> Tim Bish
> twitter: @tabish121
> blog: http://timbish.blogspot.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
> For additional commands, e-mail: users-help@qpid.apache.org
>
>


-- 
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: [Qpid JMS 0.11.1] Nullpointer exception when providing an empty string to the ConnectionFactory

Posted by Adel Boutros <Ad...@live.com>.
Hello Tim,


I took a look on the master brunch of the github repo and indeed it seems to be fixed.


Regards,

Adel


________________________________
From: Timothy Bish <ta...@gmail.com>
Sent: Friday, January 13, 2017 3:30:59 PM
To: users@qpid.apache.org
Subject: Re: [Qpid JMS 0.11.1] Nullpointer exception when providing an empty string to the ConnectionFactory

On 01/13/2017 08:41 AM, Adel Boutros wrote:
> Hello,
>
>
> While playing around with the JMS API, we noticed that if an empty string is passed to the JmsConnectionFactory constructor, it will throw back a NullPointerException because it tries to access the ".toString" of a NULL URL (See createURI).
>
>
> Do you agree that it would be better to throw an exception which clearly says an empty String URL is forbidden? If yes, I will add a jira issue for it.
>
>
> public static void main(String[] args) {
>      new JmsConnectionFactory("");
> }
>
>
> Output
>
> ------------
>
> Exception in thread "main" java.lang.NullPointerException
> at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:115)
> at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:111)
>
>
> Regards,
>
> Adel
>

I will take a look at the code again, some things were fixed recently in
QPIDJMS-245 but there's probably a few more defensive checks needed to
keep people from hitting this.


--
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Re: [Qpid JMS 0.11.1] Nullpointer exception when providing an empty string to the ConnectionFactory

Posted by Timothy Bish <ta...@gmail.com>.
On 01/13/2017 08:41 AM, Adel Boutros wrote:
> Hello,
>
>
> While playing around with the JMS API, we noticed that if an empty string is passed to the JmsConnectionFactory constructor, it will throw back a NullPointerException because it tries to access the ".toString" of a NULL URL (See createURI).
>
>
> Do you agree that it would be better to throw an exception which clearly says an empty String URL is forbidden? If yes, I will add a jira issue for it.
>
>
> public static void main(String[] args) {
>      new JmsConnectionFactory("");
> }
>
>
> Output
>
> ------------
>
> Exception in thread "main" java.lang.NullPointerException
> at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:115)
> at org.apache.qpid.jms.JmsConnectionFactory.<init>(JmsConnectionFactory.java:111)
>
>
> Regards,
>
> Adel
>

I will take a look at the code again, some things were fixed recently in 
QPIDJMS-245 but there's probably a few more defensive checks needed to 
keep people from hitting this.


-- 
Tim Bish
twitter: @tabish121
blog: http://timbish.blogspot.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org