diff --git a/gradle.properties b/gradle.properties index 229d380..516a2d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -version=0.31.0 +version=0.31.1 diff --git a/tw-tkms-starter/src/main/java/com/transferwise/kafka/tkms/api/TkmsMessage.java b/tw-tkms-starter/src/main/java/com/transferwise/kafka/tkms/api/TkmsMessage.java index 4b66cba..14b4536 100644 --- a/tw-tkms-starter/src/main/java/com/transferwise/kafka/tkms/api/TkmsMessage.java +++ b/tw-tkms-starter/src/main/java/com/transferwise/kafka/tkms/api/TkmsMessage.java @@ -6,6 +6,7 @@ import java.nio.charset.StandardCharsets; import java.time.Instant; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.UUID; @@ -107,6 +108,17 @@ public TkmsMessage addPriorityHeader(long priority) { ); } + /** + * Copy the passed headers into a ModifiableList to avoid UnsupportedOperationException when `addHeader` is called. + * @param headers headers to copy + * @return TkmsMessage + */ + public TkmsMessage setHeaders(List
headers) { + this.headers = new ArrayList<>(headers); + + return this; + } + public TkmsMessage addHeader(Header header) { if (headers == null) { headers = new ArrayList<>();