From a3a5d3f8ac878bd496979364c284a15af1b4f77a Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Wed, 4 Oct 2023 11:18:34 +0100 Subject: [PATCH 1/2] Use tryAdd when setting the Content-Type --- .../java/com/microsoft/kiota/RequestInformation.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java index 2abf1aeff..e5af21c41 100644 --- a/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java +++ b/components/abstractions/src/main/java/com/microsoft/kiota/RequestInformation.java @@ -201,7 +201,7 @@ public void setResponseHandler(@Nonnull ResponseHandler responseHandler) { public void setStreamContent(@Nonnull final InputStream value) { Objects.requireNonNull(value); this.content = value; - headers.add(CONTENT_TYPE_HEADER, BINARY_CONTENT_TYPE); + headers.tryAdd(CONTENT_TYPE_HEADER, BINARY_CONTENT_TYPE); } private static final String SERIALIZE_ERROR = "could not serialize payload"; private static final String SPAN_NAME = "setContentFromParsable"; @@ -217,7 +217,7 @@ public void setContentFromParsable(@Nonnull final RequestAd final Span span = GlobalOpenTelemetry.getTracer(OBSERVABILITY_TRACER_NAME).spanBuilder(SPAN_NAME).startSpan(); try (final Scope scope = span.makeCurrent()) { try(final SerializationWriter writer = getSerializationWriter(requestAdapter, contentType, values)) { - headers.add(CONTENT_TYPE_HEADER, contentType); + headers.tryAdd(CONTENT_TYPE_HEADER, contentType); if (values.length > 0) { setRequestType(values[0], span); } @@ -249,7 +249,7 @@ public void setContentFromParsable(@Nonnull final RequestAd effectiveContentType += "; boundary=" + multipartBody.getBoundary(); multipartBody.requestAdapter = requestAdapter; } - headers.add(CONTENT_TYPE_HEADER, effectiveContentType); + headers.tryAdd(CONTENT_TYPE_HEADER, effectiveContentType); setRequestType(value, span); writer.writeObjectValue(null, value); this.content = writer.getSerializedContent(); @@ -286,7 +286,7 @@ public void setContentFromScalar(@Nonnull final RequestAdapter requestAdapte final Span span = GlobalOpenTelemetry.getTracer(OBSERVABILITY_TRACER_NAME).spanBuilder(SPAN_NAME).startSpan(); try (final Scope scope = span.makeCurrent()) { try(final SerializationWriter writer = getSerializationWriter(requestAdapter, contentType, value)) { - headers.add(CONTENT_TYPE_HEADER, contentType); + headers.tryAdd(CONTENT_TYPE_HEADER, contentType); setRequestType(value, span); final Class valueClass = value.getClass(); if(valueClass.equals(String.class)) @@ -341,7 +341,7 @@ public void setContentFromScalarCollection(@Nonnull final RequestAdapter req final Span span = GlobalOpenTelemetry.getTracer(OBSERVABILITY_TRACER_NAME).spanBuilder(SPAN_NAME).startSpan(); try (final Scope scope = span.makeCurrent()) { try(final SerializationWriter writer = getSerializationWriter(requestAdapter, contentType, values)) { - headers.add(CONTENT_TYPE_HEADER, contentType); + headers.tryAdd(CONTENT_TYPE_HEADER, contentType); if (values.length > 0) setRequestType(values[0], span); writer.writeCollectionOfPrimitiveValues(null, Arrays.asList(values)); From 0f73f38f8b3a393e97753b0f7bbd2abb51d8c228 Mon Sep 17 00:00:00 2001 From: Andrea Peruffo Date: Fri, 6 Oct 2023 12:02:24 +0100 Subject: [PATCH 2/2] Changelog and version --- CHANGELOG.md | 6 ++++++ gradle.properties | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f3ab3872..88aa4708e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +## [0.7.6] - 2023-10-09 + +### Changed + +- Use `tryAdd` instead of `add` in all of the `setContentFrom...` methods + ## [0.7.5] - 2023-10-04 ### Added diff --git a/gradle.properties b/gradle.properties index 0e6ceb8a5..534686254 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ org.gradle.caching=true mavenGroupId = com.microsoft.kiota mavenMajorVersion = 0 mavenMinorVersion = 7 -mavenPatchVersion = 5 +mavenPatchVersion = 6 mavenArtifactSuffix = #These values are used to run functional tests