Skip to content

Commit 54a9323

Browse files
committed
Add support for "String<any suffix>"-typed attribute values
Also tag the artifact version to help the build process.
1 parent 4292004 commit 54a9323

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.amazonaws</groupId>
88
<artifactId>amazon-sqs-java-messaging-lib</artifactId>
9-
<version>1.0.6</version>
9+
<version>1.0.6.receivenowait</version>
1010
<packaging>jar</packaging>
1111
<name>Amazon SQS Java Messaging Library</name>
1212
<description>The Amazon SQS Java Messaging Library holds the Java Message Service compatible classes, that are used

src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,9 +1192,7 @@ private static String getType(Object value) throws JMSException {
11921192
}
11931193

11941194
private static Object getObjectValue(String value, String type) throws JMSException {
1195-
if (STRING.equals(type) || NUMBER.equals(type)) {
1196-
return value;
1197-
} else if (INT.equals(type)) {
1195+
if (INT.equals(type)) {
11981196
return Integer.valueOf(value);
11991197
} else if (LONG.equals(type)) {
12001198
return Long.valueOf(value);
@@ -1211,6 +1209,8 @@ private static Object getObjectValue(String value, String type) throws JMSExcept
12111209
return Float.valueOf(value);
12121210
} else if (SHORT.equals(type)) {
12131211
return Short.valueOf(value);
1212+
} else if (type != null && (type.startsWith(STRING) || type.startsWith(NUMBER))) {
1213+
return value;
12141214
} else {
12151215
throw new JMSException(type + " is not a supported JMS property type");
12161216
}

src/test/java/com/amazon/sqs/javamessaging/message/SQSMessageTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public class SQSMessageTest {
5353
final String myShort = "myShort";
5454
final String myByte = "myByte";
5555
final String myString = "myString";
56+
final String myCustomString = "myCustomString";
5657
final String myNumber = "myNumber";
5758

5859
@Before
@@ -326,6 +327,10 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
326327
.withDataType(SQSMessagingClientConstants.STRING)
327328
.withStringValue("StringValue"));
328329

330+
messageAttributes.put(myCustomString, new MessageAttributeValue()
331+
.withDataType(SQSMessagingClientConstants.NUMBER + ".custom")
332+
.withStringValue("['one', 'two']"));
333+
329334
messageAttributes.put(myNumber, new MessageAttributeValue()
330335
.withDataType(SQSMessagingClientConstants.NUMBER)
331336
.withStringValue("500"));
@@ -374,6 +379,10 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
374379
Assert.assertEquals(message.getObjectProperty(myString), "StringValue");
375380
Assert.assertEquals(message.getStringProperty(myString), "StringValue");
376381

382+
Assert.assertTrue(message.propertyExists(myCustomString));
383+
Assert.assertEquals(message.getObjectProperty(myCustomString), "['one', 'two']");
384+
Assert.assertEquals(message.getStringProperty(myCustomString), "['one', 'two']");
385+
377386
Assert.assertTrue(message.propertyExists(myNumber));
378387
Assert.assertEquals(message.getObjectProperty(myNumber), "500");
379388
Assert.assertEquals(message.getStringProperty(myNumber), "500");
@@ -395,6 +404,7 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
395404
myShort,
396405
myByte,
397406
myString,
407+
myCustomString,
398408
myNumber,
399409
JMSX_DELIVERY_COUNT));
400410

0 commit comments

Comments
 (0)