Author: ritchiem
Date: Mon May 7 02:28:15 2007
New Revision: 535809
URL: http://svn.apache.org/viewvc?view=rev&rev=535809
Log:
QPID-466 Updated FieldTable to ensure no Decimal value is set that is larger
than can be transmitted over AMQP.
That is a max scale value of Byte.MAX_VALUE and value of up to
Integer.MAX_VALUE.
Additional tests to ensure this is the case.
Modified:
incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
Modified:
incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java?view=diff&rev=535809&r1=535808&r2=535809
==============================================================================
---
incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
(original)
+++
incubator/qpid/branches/M2/java/client/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
Mon May 7 02:28:15 2007
@@ -194,6 +194,30 @@
BigDecimal bd = new BigDecimal(Integer.MAX_VALUE);
((AMQMessage) m).setDecimalProperty(new AMQShortString("decimal"),
bd.setScale(Byte.MAX_VALUE));
+
+ bd = new BigDecimal((long) Integer.MAX_VALUE + 1L);
+
+ try
+ {
+ ((AMQMessage) m).setDecimalProperty(new
AMQShortString("decimal-bad-value"), bd.setScale(Byte.MAX_VALUE));
+ fail("UnsupportedOperationException should be thrown as value
can't be correctly transmitted");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // normal path.
+ }
+
+
+ try
+ {
+ ((AMQMessage) m).setDecimalProperty(new
AMQShortString("decimal-bad-scale"), bd.setScale(Byte.MAX_VALUE + 1));
+ fail("UnsupportedOperationException should be thrown as scale
can't be correctly transmitted");
+ }
+ catch (UnsupportedOperationException uoe)
+ {
+ // normal path.
+ }
+
//Void
((AMQMessage) m).setVoidProperty(new AMQShortString("void"));
@@ -254,7 +278,7 @@
"Test", m.getStringProperty("String"));
// AMQP Tests Specific values
-
+
Assert.assertEquals("Check Timestamp properties are correctly
transported",
m.getStringProperty("time-str"),
((AMQMessage) m).getTimestampProperty(new
AMQShortString("time")).toString());
Modified:
incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
URL:
http://svn.apache.org/viewvc/incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java?view=diff&rev=535809&r1=535808&r2=535809
==============================================================================
---
incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
(original)
+++
incubator/qpid/branches/M2/java/common/src/main/java/org/apache/qpid/framing/FieldTable.java
Mon May 7 02:28:15 2007
@@ -552,6 +552,16 @@
public Object setDecimal(AMQShortString string, BigDecimal decimal)
{
+ if (decimal.longValue() > Integer.MAX_VALUE)
+ {
+ throw new UnsupportedOperationException("AMQP doesnot support
decimals larger than " + Integer.MAX_VALUE);
+ }
+
+ if (decimal.scale() > Byte.MAX_VALUE)
+ {
+ throw new UnsupportedOperationException("AMQP doesnot support
decimal scales larger than " + Byte.MAX_VALUE);
+ }
+
return setProperty(string, AMQType.DECIMAL.asTypedValue(decimal));
}