diff --git a/CHANGELOG.md b/CHANGELOG.md index 8eec1b6..1410d0c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.31.1] - 2024-10-09 + +### Fixed +- Override the lombok generated `TkmsMessage#setHeaders` to copy the passed headers into a mutable `ArrayList` in order to avoid `UnsupportedOperationException` + ## [0.31.0] - 2024-10-07 ### Changed 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<>();