Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: microsoft/kiota-java
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.1.2
Choose a base ref
...
head repository: microsoft/kiota-java
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.3
Choose a head ref
  • 8 commits
  • 7 files changed
  • 4 contributors

Commits on Mar 27, 2024

  1. Bump io.opentelemetry.semconv:opentelemetry-semconv

    Bumps [io.opentelemetry.semconv:opentelemetry-semconv](https://github.com/open-telemetry/semantic-conventions-java) from 1.23.1-alpha to 1.24.0-alpha.
    - [Release notes](https://github.com/open-telemetry/semantic-conventions-java/releases)
    - [Changelog](https://github.com/open-telemetry/semantic-conventions-java/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/open-telemetry/semantic-conventions-java/commits)
    
    ---
    updated-dependencies:
    - dependency-name: io.opentelemetry.semconv:opentelemetry-semconv
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 27, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    421ae28 View commit details
  2. Bump io.opentelemetry.semconv:opentelemetry-semconv

    Bumps [io.opentelemetry.semconv:opentelemetry-semconv](https://github.com/open-telemetry/semantic-conventions-java) from 1.23.1-alpha to 1.24.0-alpha.
    - [Release notes](https://github.com/open-telemetry/semantic-conventions-java/releases)
    - [Changelog](https://github.com/open-telemetry/semantic-conventions-java/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/open-telemetry/semantic-conventions-java/commits)
    
    ---
    updated-dependencies:
    - dependency-name: io.opentelemetry.semconv:opentelemetry-semconv
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Mar 27, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    80dad8b View commit details

Commits on Mar 28, 2024

  1. Merge remote-tracking branch 'origin/dependabot/gradle/components/htt…

    …p/okHttp/io.opentelemetry.semconv-opentelemetry-semconv-1.24.0-alpha' into dependabot/gradle/components/http/okHttp/android/io.opentelemetry.semconv-opentelemetry-semconv-1.24.0-alpha
    Andrew Omondi committed Mar 28, 2024
    Copy the full SHA
    9669f43 View commit details
  2. Fixes stuff

    Andrew Omondi committed Mar 28, 2024
    Copy the full SHA
    a191db9 View commit details
  3. Merge pull request #1144 from microsoft/dependabot/gradle/components/…

    …http/okHttp/android/io.opentelemetry.semconv-opentelemetry-semconv-1.24.0-alpha
    
    Bump io.opentelemetry.semconv:opentelemetry-semconv from 1.23.1-alpha to 1.24.0-alpha in /components/http/okHttp/android
    github-actions[bot] authored Mar 28, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    46cd68f View commit details

Commits on Apr 2, 2024

  1. Fixes bug in serializer

    Andrew Omondi committed Apr 2, 2024
    Copy the full SHA
    f6ca2e4 View commit details
  2. Bump coverage

    Andrew Omondi committed Apr 2, 2024
    Copy the full SHA
    03d9d28 View commit details
  3. Merge pull request #1148 from microsoft/andrueastman/serializerBug

    Fixes IllegalStateException when jsonarray is in additionalData
    andrueastman authored Apr 2, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b907aaf View commit details
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [1.1.3] - 2024-04-02

### Changed

- Fixes a bug in the seriliazer that would `IllegalStateException` for json arrays in the additional data.

## [1.1.2] - 2024-03-26

### Changed
3 changes: 2 additions & 1 deletion components/http/okHttp/gradle/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -11,7 +11,8 @@ dependencies {
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'io.opentelemetry:opentelemetry-api:1.36.0'
implementation 'io.opentelemetry:opentelemetry-context:1.36.0'
implementation 'io.opentelemetry.semconv:opentelemetry-semconv:1.23.1-alpha'
implementation 'io.opentelemetry.semconv:opentelemetry-semconv:1.24.0-alpha'
implementation 'io.opentelemetry.semconv:opentelemetry-semconv-incubating:1.24.0-alpha'
implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'
api 'com.squareup.okhttp3:okhttp:4.12.0'

Original file line number Diff line number Diff line change
@@ -19,7 +19,11 @@
import io.opentelemetry.api.trace.StatusCode;
import io.opentelemetry.context.Context;
import io.opentelemetry.context.Scope;
import io.opentelemetry.semconv.SemanticAttributes;
import io.opentelemetry.semconv.HttpAttributes;
import io.opentelemetry.semconv.NetworkAttributes;
import io.opentelemetry.semconv.ServerAttributes;
import io.opentelemetry.semconv.UrlAttributes;
import io.opentelemetry.semconv.incubating.HttpIncubatingAttributes;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;
@@ -720,17 +724,18 @@ private Response getHttpResponseMessage(
final int contentLengthHeaderValueAsInt =
Integer.parseInt(contentLengthHeaderValue);
spanForAttributes.setAttribute(
SemanticAttributes.HTTP_RESPONSE_BODY_SIZE, contentLengthHeaderValueAsInt);
HttpIncubatingAttributes.HTTP_RESPONSE_BODY_SIZE,
contentLengthHeaderValueAsInt);
}
final String contentTypeHeaderValue = getHeaderValue(response, "Content-Length");
if (contentTypeHeaderValue != null && !contentTypeHeaderValue.isEmpty()) {
spanForAttributes.setAttribute(
"http.response_content_type", contentTypeHeaderValue);
}
spanForAttributes.setAttribute(
SemanticAttributes.HTTP_RESPONSE_STATUS_CODE, response.code());
HttpAttributes.HTTP_RESPONSE_STATUS_CODE, response.code());
spanForAttributes.setAttribute(
SemanticAttributes.NETWORK_PROTOCOL_VERSION,
NetworkAttributes.NETWORK_PROTOCOL_VERSION,
response.protocol().toString().toUpperCase(Locale.ROOT));
return this.retryCAEResponseIfRequired(
response, requestInfo, span, spanForAttributes, claims);
@@ -786,7 +791,7 @@ private Response retryCAEResponseIfRequired(
}
closeResponse(true, response);
span.addEvent(authenticateChallengedEventKey);
spanForAttributes.setAttribute(SemanticAttributes.HTTP_RESEND_COUNT, 1);
spanForAttributes.setAttribute(HttpAttributes.HTTP_REQUEST_RESEND_COUNT, 1);
return this.getHttpResponseMessage(
requestInfo, span, spanForAttributes, responseClaims);
}
@@ -871,14 +876,14 @@ private void setBaseUrlForRequestInformation(@Nonnull final RequestInformation r
.startSpan();
try (final Scope scope = span.makeCurrent()) {
spanForAttributes.setAttribute(
SemanticAttributes.HTTP_REQUEST_METHOD, requestInfo.httpMethod.toString());
HttpAttributes.HTTP_REQUEST_METHOD, requestInfo.httpMethod.toString());
final URL requestURL = requestInfo.getUri().toURL();
if (obsOptions.getIncludeEUIIAttributes()) {
spanForAttributes.setAttribute(SemanticAttributes.URL_FULL, requestURL.toString());
spanForAttributes.setAttribute(UrlAttributes.URL_FULL, requestURL.toString());
}
spanForAttributes.setAttribute("http.port", requestURL.getPort());
spanForAttributes.setAttribute(SemanticAttributes.SERVER_ADDRESS, requestURL.getHost());
spanForAttributes.setAttribute(SemanticAttributes.URL_SCHEME, requestURL.getProtocol());
spanForAttributes.setAttribute(ServerAttributes.SERVER_ADDRESS, requestURL.getHost());
spanForAttributes.setAttribute(UrlAttributes.URL_SCHEME, requestURL.getProtocol());

RequestBody body =
requestInfo.content == null
@@ -922,7 +927,8 @@ public long contentLength() throws IOException {
}
if (length > 0) {
spanForAttributes.setAttribute(
SemanticAttributes.HTTP_REQUEST_BODY_SIZE, length);
HttpIncubatingAttributes.HTTP_REQUEST_BODY_SIZE,
length);
}
return length;
}
Original file line number Diff line number Diff line change
@@ -163,8 +163,8 @@ public JsonParseNode(@Nonnull final JsonElement node) {
}
}

private <T> List<T> iterateOnArray(Function<JsonParseNode, T> fn) {
JsonArray array = currentNode.getAsJsonArray();
private <T> List<T> iterateOnArray(JsonElement jsonElement, Function<JsonParseNode, T> fn) {
JsonArray array = jsonElement.getAsJsonArray();
final Iterator<JsonElement> sourceIterator = array.iterator();
final List<T> result = new ArrayList<>();
while (sourceIterator.hasNext()) {
@@ -182,7 +182,8 @@ private <T> List<T> iterateOnArray(Function<JsonParseNode, T> fn) {
if (currentNode.isJsonNull()) {
return null;
} else if (currentNode.isJsonArray()) {
return iterateOnArray(itemNode -> getPrimitiveValue(targetClass, itemNode));
return iterateOnArray(
currentNode, itemNode -> getPrimitiveValue(targetClass, itemNode));
} else throw new RuntimeException("invalid state expected to have an array node");
}

@@ -192,7 +193,7 @@ private <T> List<T> iterateOnArray(Function<JsonParseNode, T> fn) {
if (currentNode.isJsonNull()) {
return null;
} else if (currentNode.isJsonArray()) {
return iterateOnArray(itemNode -> itemNode.getObjectValue(factory));
return iterateOnArray(currentNode, itemNode -> itemNode.getObjectValue(factory));
} else return null;
}

@@ -202,7 +203,7 @@ private <T> List<T> iterateOnArray(Function<JsonParseNode, T> fn) {
if (currentNode.isJsonNull()) {
return null;
} else if (currentNode.isJsonArray()) {
return iterateOnArray(itemNode -> itemNode.getEnumValue(enumParser));
return iterateOnArray(currentNode, itemNode -> itemNode.getEnumValue(enumParser));
} else throw new RuntimeException("invalid state expected to have an array node");
}

@@ -242,7 +243,7 @@ else if (element.isJsonPrimitive()) {
return new UntypedObject(propertiesMap);

} else if (element.isJsonArray()) {
return new UntypedArray(iterateOnArray(JsonParseNode::getUntypedValue));
return new UntypedArray(iterateOnArray(element, JsonParseNode::getUntypedValue));
}

throw new RuntimeException(
Original file line number Diff line number Diff line change
@@ -3,6 +3,8 @@
import static org.junit.jupiter.api.Assertions.*;

import com.google.gson.JsonParser;
import com.microsoft.kiota.serialization.mocks.MyEnum;
import com.microsoft.kiota.serialization.mocks.TestEntity;
import com.microsoft.kiota.serialization.mocks.UntypedTestEntity;

import org.junit.jupiter.api.Test;
@@ -16,6 +18,11 @@
class JsonParseNodeTests {
private static final JsonParseNodeFactory _parseNodeFactory = new JsonParseNodeFactory();
private static final String contentType = "application/json";

private static final String testJsonString =
"{\"displayName\":\"My"
+ " Group\",\"phones\":[\"+1234567890\"],\"myEnum\":\"VALUE1\",\"enumCollection\":[\"VALUE1\"],\"id\":\"11111111-1111-1111-1111-111111111111"
+ "\",\"members@delta\":[{\"@odata.type\":\"#microsoft.graph.user\",\"id\":\"22222222-2222-2222-2222-222222222222\"}]}";
private static final String testUntypedJson =
"{\r\n"
+ " \"@odata.context\":"
@@ -95,6 +102,20 @@ void testInvalidOffsetDateTimeStringThrowsException(final String dateTimeString)
}
}

@Test
void getEntityWithArrayInAdditionalData() throws UnsupportedEncodingException {
final var rawResponse = new ByteArrayInputStream(testJsonString.getBytes("UTF-8"));
final var parseNode = _parseNodeFactory.getParseNode(contentType, rawResponse);
// Act
var entity = parseNode.getObjectValue(TestEntity::createFromDiscriminatorValue);
assertEquals("11111111-1111-1111-1111-111111111111", entity.getId());
assertEquals(1, entity.getPhones().size());
assertEquals(MyEnum.MY_VALUE1, entity.getMyEnum());
assertEquals(1, entity.getEnumCollection().size());
final var arrayValue = (UntypedArray) entity.getAdditionalData().get("members@delta");
assertEquals(1, arrayValue.getValue().spliterator().estimateSize());
}

@Test
void GetEntityWithUntypedNodesFromJson() throws UnsupportedEncodingException {
final var rawResponse = new ByteArrayInputStream(testUntypedJson.getBytes("UTF-8"));
Original file line number Diff line number Diff line change
@@ -9,7 +9,9 @@
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.Consumer;
@@ -25,6 +27,16 @@ public void setId(String _id) {
this._id = _id;
}

private List<String> _phones;

public List<String> getPhones() {
return _phones;
}

public void setPhones(List<String> _phones) {
this._phones = new ArrayList<String>(_phones);
}

private String _officeLocation;

public String getOfficeLocation() {
@@ -85,6 +97,16 @@ public void setMyEnum(MyEnum value) {
this._myEnum = value;
}

private List<MyEnum> _enumCollection;

public List<MyEnum> getEnumCollection() {
return _enumCollection;
}

public void setEnumCollection(List<MyEnum> value) {
this._enumCollection = new ArrayList<MyEnum>(value);
}

private OffsetDateTime _createdDateTime;

public OffsetDateTime getCreatedDateTime() {
@@ -134,11 +156,21 @@ public Map<String, Consumer<ParseNode>> getFieldDeserializers() {
(n) -> {
setMyEnum(n.getEnumValue(MyEnum::forValue));
});
put(
"enumCollection",
(n) -> {
setEnumCollection(n.getCollectionOfEnumValues(MyEnum::forValue));
});
put(
"createdDateTime",
(n) -> {
setCreatedDateTime(n.getOffsetDateTimeValue());
});
put(
"phones",
(n) -> {
setPhones(n.getCollectionOfPrimitiveValues(String.class));
});
}
};
}
@@ -153,7 +185,9 @@ public void serialize(SerializationWriter writer) {
writer.writeLocalTimeValue("startWorkTime", getStartWorkTime());
writer.writeLocalTimeValue("endWorkTime", getEndWorkTime());
writer.writeEnumValue("myEnum", getMyEnum());
writer.writeCollectionOfEnumValues("enumCollection", getEnumCollection());
writer.writeOffsetDateTimeValue("createdDateTime", getCreatedDateTime());
writer.writeCollectionOfPrimitiveValues("phones", getPhones());
writer.writeAdditionalData(getAdditionalData());
}

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ org.gradle.caching=true
mavenGroupId = com.microsoft.kiota
mavenMajorVersion = 1
mavenMinorVersion = 1
mavenPatchVersion = 2
mavenPatchVersion = 3
mavenArtifactSuffix =

#These values are used to run functional tests