Skip to content

Commit 81f7b74

Browse files
Fix issue with null headers
1 parent 26e5687 commit 81f7b74

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

common/src/main/java/dev/restate/common/RequestBuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public interface RequestBuilder<Req, Res> extends Request<Req, Res> {
1818
* @param idempotencyKey Idempotency key to attach in the request.
1919
* @return this instance, so the builder can be used fluently.
2020
*/
21-
RequestBuilder<Req, Res> idempotencyKey(String idempotencyKey);
21+
RequestBuilder<Req, Res> idempotencyKey(@Nullable String idempotencyKey);
2222

2323
/**
2424
* @param idempotencyKey Idempotency key to attach in the request.
@@ -40,7 +40,7 @@ public interface RequestBuilder<Req, Res> extends Request<Req, Res> {
4040
* @param newHeaders headers to send together with the request.
4141
* @return this instance, so the builder can be used fluently.
4242
*/
43-
RequestBuilder<Req, Res> headers(Map<String, String> newHeaders);
43+
RequestBuilder<Req, Res> headers(@Nullable Map<String, String> newHeaders);
4444

4545
/**
4646
* @param headers headers to send together with the request. This will overwrite the already

common/src/main/java/dev/restate/common/RequestImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,12 @@ public Builder<Req, Res> header(String key, String value) {
155155
*/
156156
@Override
157157
public Builder<Req, Res> headers(Map<String, String> newHeaders) {
158-
if (this.headers == null) {
159-
this.headers = new LinkedHashMap<>();
158+
if (newHeaders != null) {
159+
if (this.headers == null) {
160+
this.headers = new LinkedHashMap<>();
161+
}
162+
this.headers.putAll(newHeaders);
160163
}
161-
this.headers.putAll(newHeaders);
162164
return this;
163165
}
164166

0 commit comments

Comments
 (0)