Skip to content

Commit 301be09

Browse files
authored
Merge pull request #85 from rabbitmq/validate-annotation-key
Validate key annotation to start with x-
2 parents cb92681 + be5bc7c commit 301be09

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/main/java/com/rabbitmq/client/amqp/impl/AmqpMessage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ public Object annotation(String key) {
499499

500500
@Override
501501
public Message annotation(String key, Object value) {
502+
Utils.validateMessageAnnotationKey(key);
502503
callOnDelegate(m -> m.annotation(key, value));
503504
return this;
504505
}

src/main/java/com/rabbitmq/client/amqp/impl/Utils.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ private static boolean isJava21OrMore() {
100100
}
101101

102102
static void checkMessageAnnotations(Map<String, Object> annotations) {
103-
annotations.forEach(
104-
(k, v) -> {
105-
if (!k.startsWith("x-")) {
106-
throw new IllegalArgumentException(
107-
"Message annotation keys must start with 'x-': " + k);
108-
}
109-
});
103+
annotations.forEach((k, v) -> validateMessageAnnotationKey(k));
104+
}
105+
106+
static void validateMessageAnnotationKey(String key) {
107+
if (!key.startsWith("x-")) {
108+
throw new IllegalArgumentException("Message annotation keys must start with 'x-': " + key);
109+
}
110110
}
111111

112112
private static class NamedThreadFactory implements ThreadFactory {

0 commit comments

Comments
 (0)