diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ea7521e7..a5555835a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.1.12] - 2024-05-21 + +### Changed + +- Fixed a bug where large responses would make the client fail. [microsoftgraph/msgraph-sdk-java#2009](https://github.com/microsoftgraph/msgraph-sdk-java/issues/2009) + ## [1.1.11] - 2024-05-07 ### Changed diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java index d2b030d40..602f64567 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/OkHttpRequestAdapter.java @@ -53,8 +53,8 @@ /** RequestAdapter implementation for OkHttp */ public class OkHttpRequestAdapter implements com.microsoft.kiota.RequestAdapter { - private static final String contentTypeHeaderKey = "Content-Type"; - private static final String contentLengthHeaderKey = "Content-Length"; + private static final String CONTENT_LENGTH_HEADER_KEY = "Content-Length"; + private static final String CONTENT_TYPE_HEADER_KEY = "Content-Type"; @Nonnull private final Call.Factory client; @Nonnull private final AuthenticationProvider authProvider; @Nonnull private final ObservabilityOptions obsOptions; @@ -715,17 +715,18 @@ private Response getHttpResponseMessage( getRequestFromRequestInformation( requestInfo, span, spanForAttributes)) .execute(); - final String contentLengthHeaderValue = getHeaderValue(response, "Content-Length"); + final String contentLengthHeaderValue = + getHeaderValue(response, CONTENT_LENGTH_HEADER_KEY); if (contentLengthHeaderValue != null && !contentLengthHeaderValue.isEmpty()) { - final int contentLengthHeaderValueAsInt = - Integer.parseInt(contentLengthHeaderValue); + final long contentLengthHeaderValueAsLong = + Long.parseLong(contentLengthHeaderValue); spanForAttributes.setAttribute( - EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE, contentLengthHeaderValueAsInt); + EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE, contentLengthHeaderValueAsLong); } - final String contentTypeHeaderValue = getHeaderValue(response, "Content-Length"); + final String contentTypeHeaderValue = getHeaderValue(response, CONTENT_TYPE_HEADER_KEY); if (contentTypeHeaderValue != null && !contentTypeHeaderValue.isEmpty()) { spanForAttributes.setAttribute( - "http.response_content_type", contentTypeHeaderValue); + CUSTOM_HTTP_RESPONSE_CONTENT_TYPE, contentTypeHeaderValue); } spanForAttributes.setAttribute(HTTP_RESPONSE_STATUS_CODE, response.code()); spanForAttributes.setAttribute( @@ -886,14 +887,14 @@ private void setBaseUrlForRequestInformation(@Nonnull final RequestInformation r public MediaType contentType() { final Set contentTypes = requestInfo.headers.getOrDefault( - contentTypeHeaderKey, new HashSet<>()); + CONTENT_TYPE_HEADER_KEY, new HashSet<>()); if (contentTypes.isEmpty()) { return null; } else { final String contentType = contentTypes.toArray(new String[] {})[0]; spanForAttributes.setAttribute( - "http.request_content_type", contentType); + CUSTOM_HTTP_REQUEST_CONTENT_TYPE, contentType); return MediaType.parse(contentType); } } @@ -902,7 +903,7 @@ public MediaType contentType() { public long contentLength() throws IOException { final Set contentLength = requestInfo.headers.getOrDefault( - contentLengthHeaderKey, new HashSet<>()); + CONTENT_LENGTH_HEADER_KEY, new HashSet<>()); if (!contentLength.isEmpty()) { return Long.parseLong( contentLength.toArray(new String[] {})[0]); diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java index 02e8ef458..d5546409a 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/TelemetrySemanticConventions.java @@ -5,24 +5,30 @@ import io.opentelemetry.api.common.AttributeKey; -public class TelemetrySemanticConventions { +public final class TelemetrySemanticConventions { + private TelemetrySemanticConventions() {} // https://opentelemetry.io/docs/specs/semconv/attributes-registry/ - public static final AttributeKey HTTP_RESPONSE_STATUS_CODE = + public static final AttributeKey HTTP_RESPONSE_STATUS_CODE = longKey("http.response.status_code"); // stable - public static final AttributeKey HTTP_REQUEST_RESEND_COUNT = + public static final AttributeKey HTTP_REQUEST_RESEND_COUNT = longKey("http.request.resend_count"); // stable - public static final AttributeKey HTTP_REQUEST_METHOD = + public static final AttributeKey HTTP_REQUEST_METHOD = stringKey("http.request.method"); // stable - public static final AttributeKey NETWORK_PROTOCOL_VERSION = + public static final AttributeKey NETWORK_PROTOCOL_VERSION = stringKey("network.protocol.version"); // stable - public static final AttributeKey URL_FULL = stringKey("url.full"); // stable - public static final AttributeKey URL_SCHEME = stringKey("url.scheme"); // stable - public static final AttributeKey SERVER_ADDRESS = stringKey("server.address"); // stable - public static final AttributeKey SERVER_PORT = longKey("server.port"); // stable + public static final AttributeKey URL_FULL = stringKey("url.full"); // stable + public static final AttributeKey URL_SCHEME = stringKey("url.scheme"); // stable + public static final AttributeKey SERVER_ADDRESS = stringKey("server.address"); // stable + public static final AttributeKey SERVER_PORT = longKey("server.port"); // stable - public static final AttributeKey EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE = + public static final AttributeKey EXPERIMENTAL_HTTP_RESPONSE_BODY_SIZE = longKey("http.response.body.size"); // experimental - public static final AttributeKey EXPERIMENTAL_HTTP_REQUEST_BODY_SIZE = + public static final AttributeKey EXPERIMENTAL_HTTP_REQUEST_BODY_SIZE = longKey("http.request.body.size"); // experimental + + public static final AttributeKey CUSTOM_HTTP_RESPONSE_CONTENT_TYPE = + stringKey("http.response_content_type"); // custom + public static final AttributeKey CUSTOM_HTTP_REQUEST_CONTENT_TYPE = + stringKey("http.request_content_type"); // custom } diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/UserAgentHandlerOption.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/UserAgentHandlerOption.java index 28039daac..f01bddc01 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/UserAgentHandlerOption.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/UserAgentHandlerOption.java @@ -13,7 +13,7 @@ public UserAgentHandlerOption() {} private boolean enabled = true; @Nonnull private String productName = "kiota-java"; - @Nonnull private String productVersion = "1.1.11"; + @Nonnull private String productVersion = "1.1.12"; /** * Gets the product name to be used in the user agent header diff --git a/gradle.properties b/gradle.properties index 40cda2f94..a1a2306e6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ org.gradle.caching=true mavenGroupId = com.microsoft.kiota mavenMajorVersion = 1 mavenMinorVersion = 1 -mavenPatchVersion = 11 +mavenPatchVersion = 12 mavenArtifactSuffix = #These values are used to run functional tests