From dbbf065ef5daf67db285b87ae6f7e0f980900875 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Wed, 13 Aug 2008 13:22:31 +0000 Subject: QPID-1236: made setObjectProperty validate the passed in value git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@685536 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/message/AMQMessageDelegate_0_10.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'java/client') diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java b/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java index 5a57e7b0db..8b4488f1f9 100644 --- a/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java +++ b/java/client/src/main/java/org/apache/qpid/client/message/AMQMessageDelegate_0_10.java @@ -736,10 +736,32 @@ public class AMQMessageDelegate_0_10 implements AMQMessageDelegate setApplicationHeader(propertyName, value); } + private static final Set ALLOWED = new HashSet(); + static + { + ALLOWED.add(Boolean.class); + ALLOWED.add(Byte.class); + ALLOWED.add(Short.class); + ALLOWED.add(Integer.class); + ALLOWED.add(Long.class); + ALLOWED.add(Float.class); + ALLOWED.add(Double.class); + ALLOWED.add(Character.class); + ALLOWED.add(String.class); + ALLOWED.add(byte[].class); + } + public void setObjectProperty(String propertyName, Object object) throws JMSException { checkPropertyName(propertyName); checkWritableProperties(); + if (object != null && !ALLOWED.contains(object.getClass())) + { + throw new MessageFormatException + (String.format + ("Cannot set a %s, allowed property types are: %s", + object.getClass(), ALLOWED)); + } setApplicationHeader(propertyName, object); } -- cgit v1.2.1