Non-existent properties handling in .NET
The handling of non-existent properties in the XMS .NET is broadly consistent with the JMS specification, and also with the C and C++ implementations of XMS.
In JMS, accessing a non-existent property can result in a Java system exception when a method tries to convert the non-existent (null) value to the required type. If a property does not exist the following exceptions occur:
- getStringProperty and getObjectProperty return null
- getBooleanProperty returns false because Boolean.valueOf(null) returns false
- getIntProperty etc.throw java.lang.NumberFormatException because Integer.valueOf(null) throws the exception
If a property does not exist in XMS .NET the following exceptions occur:
- GetStringProperty and GetObjectProperty (and GetBytesProperty) return null (which is the same as Java)
- GetBooleanProperty throws System.NullReferenceException
- GetIntProperty etc. throws System.NullReferenceException
This implementation is different from Java, but it is broadly consistent
with the JMS specification, and with the XMS C and C++ interfaces.
Like the Java implementation, XMS .NET propagates any exceptions
from the System.Convert call to the caller. Unlike Java however, XMS explicitly throws
NullReferenceExceptions rather than just using the native behavior
of the .NET framework
through passing null to system conversion routines. If your application
sets a property to a String like abc
and calls GetIntProperty,
the System.FormatException thrown by Convert.ToInt32("abc") is propagated
to the caller, which is consistent with Java. MessageFormatException is thrown
only if the types used for setProperty and getProperty are incompatible.
This behavior is also consistent with Java.