activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gaurav Hariani <gau...@blackspark.com>
Subject Re: MapMessage.getInt
Date Thu, 14 Jun 2007 17:01:10 GMT
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
If you are retrieving primitive types - you could check using <br>
boolean itemExists(String name)<br>
<br>
<a
 href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/command/ActiveMQMapMessage.html#itemExists%28java.lang.String%29">http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/command/ActiveMQMapMessage.html#itemExists(java.lang.String)</a><br>
<br>
also from the spec api: <a
 href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/MapMessage.html">http://java.sun.com/j2ee/1.4/docs/api/javax/jms/MapMessage.html</a><br>
<br>
<blockquote><i>Attempting to read a null value as a primitive type must
be treated as calling the primitive's corresponding <code>valueOf(String)</code>
conversion method with a null value. Since <code>char</code> does not
support a <code>String</code> conversion, attempting to read a null
value as a <code>char</code> must throw a <code>NullPointerException</code>.</i><br>
</blockquote>
.. so you are right that it is a bug ... since Integer.valueOf(null)
throws an Exception<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
Elliotte Harold wrote:
<blockquote
 cite="mid:49aa580c0706130748h66305bc8raccb1c71a1082783@mail.gmail.com"
 type="cite">Consider simple reception code like this:
  <br>
  <br>
       MapMessage message = (MapMessage) consumer.receive(1000);
  <br>
       int x = message.getInt("foo"));
  <br>
  <br>
I notice that x is now set to zero even though there was no "foo" value
in
  <br>
the map. I would have expected an exception.
  <br>
  <br>
The JavaDoc is unclear on this point. Is this expected behavior? Can
someone
  <br>
explain to me why it behaves like this? What if zero is a legal value
for
  <br>
the map?
  <br>
  <br>
</blockquote>
</body>
</html>

Mime
View raw message