Skip to content

Commit

Permalink
Merge pull request #1582 from microsoftgraph/dev
Browse files Browse the repository at this point in the history
lfu fix release
  • Loading branch information
baywet authored Apr 22, 2024
2 parents cb2c3d9 + 0f88740 commit 9ac7e26
Show file tree
Hide file tree
Showing 12 changed files with 118 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-level-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
distribution: 'temurin'
java-version: 20
- name: Setup Android SDK
uses: android-actions/setup-android@v3.2.0
uses: android-actions/setup-android@v3.2.1
- name: Add execution right to the script
run: chmod +x gradlew
working-directory: ./android
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
with:
tag: ${{ steps.GetVersion.outputs.tag }}
- name: Queue Git Release
uses: benc-uk/workflow-dispatch@v121
uses: benc-uk/workflow-dispatch@v1
with:
workflow: Git Release
token: ${{ secrets.PERSONAL_TOKEN }}
Expand Down
36 changes: 22 additions & 14 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

## [3.1.8]

### Added

### Changed
- Changed chunkInputStream method in LargeFileUploadTask to resolve IndexOutOfBoundsException when uploading large files
- Fix Large File Upload bug where exception was thrown for completed successful uploads

## [3.1.7] - 2024-03-28

### Changed
Expand Down Expand Up @@ -60,13 +68,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- Version bump for Java SDK GA release.
- Bumps Kiota-Java abstractions, authentication, http, and serialization components for Java SDK 6.1.0 release.
- Bumps Kiota-Java abstractions, authentication, http, and serialization components for Java SDK 6.1.0 release.

## [3.0.12] - 2023-12-15

### Fixed
### Fixed

- Fixes a bug where a null collection for allowedHosts would result in failure to initialize client. [#1411](https://github.com/microsoftgraph/msgraph-sdk-java-core/pull/1411)
- Fixes a bug where a null collection for allowedHosts would result in failure to initialize client. [#1411](https://github.com/microsoftgraph/msgraph-sdk-java-core/pull/1411)

## [3.0.11] - 2023-12-08

Expand All @@ -77,7 +85,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [3.0.10] - 2023-11-27

### Changed
### Changed

- Removed the usage of reflection for enum deserialization and reordered RequestAdapter method arguments. [Kiota-Java #840](https://github.com/microsoft/kiota-java/issues/840)

Expand All @@ -100,13 +108,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Removed

- Removes 'SuppressFBWarnings' annotations and dependency.
- Removes 'SuppressFBWarnings' annotations and dependency.

## [3.0.7] - 2023-07-20

### Added

- Adds graph-java-sdk implementation of the `UrlReplaceHandler` middleware including default replacement pairs.
- Adds graph-java-sdk implementation of the `UrlReplaceHandler` middleware including default replacement pairs.
- Default replacement pair: '/users/TokenToReplace' -> '/me'

## [3.0.6] - 2023-07-11
Expand All @@ -123,11 +131,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [3.0.4] - 2023-05-03

### Added
- Added LargeFileUploadTask functionality for kiota generated service libraries.
### Added

- Added LargeFileUploadTask functionality for kiota generated service libraries.

### Fixed
### Fixed

- Fixes formatting used in the headers added by the telemetry handler to align with the [msGraph sdk spec.](https://github.com/microsoftgraph/msgraph-sdk-design/blob/master/middleware/TelemetryHandler.md)

Expand Down Expand Up @@ -171,7 +179,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
private OkHttpClient createClient(@Nonnull final IAuthenticationProvider auth) {
return HttpClients.createDefault(auth);
}

// then create the GraphServiceClient
IAuthenticationProvider authenticationProvider = ...;
GraphServiceClient
Expand All @@ -183,16 +191,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.0.20] - 2023-10-23

### Changed
### Changed

- Updates Okhttp3 to avoid transient vulnerabilty. [#1038](https://github.com/microsoftgraph/msgraph-sdk-java-core/issues/1038)
- Updates Okhttp3 to avoid transient vulnerabilty. [#1038](https://github.com/microsoftgraph/msgraph-sdk-java-core/issues/1038)

## [2.0.19] - 2023-06-20

### Changed

- Remove explicit logging of GraphServiceException in the CoreHttpProvider class. [#885](https://github.com/microsoftgraph/msgraph-sdk-java-core/issues/885)
- Thank you to @MaHa6543 for the contribution.
- Thank you to @MaHa6543 for the contribution.

## [2.0.18] - 2023-04-06

Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ buildscript {
}

dependencies {
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
classpath "com.android.tools.build:gradle:8.3.1"
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17.2"
classpath "com.android.tools.build:gradle:8.3.2"
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
}
}
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.github.spotbugs' version '6.0.9'
id 'com.github.spotbugs' version '6.0.12'
id "org.sonarqube" version "5.0.0.4638"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mavenGroupId = com.microsoft.graph
mavenArtifactId = microsoft-graph-core
mavenMajorVersion = 3
mavenMinorVersion = 1
mavenPatchVersion = 7
mavenPatchVersion = 8
mavenArtifactSuffix =

#These values are used to run functional tests
Expand Down
25 changes: 12 additions & 13 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
testImplementation 'org.mockito:mockito-inline:5.2.0'
testImplementation 'io.opentelemetry:opentelemetry-api:1.36.0'
testImplementation 'io.opentelemetry:opentelemetry-context:1.36.0'
testImplementation 'io.github.std-uritemplate:std-uritemplate:0.0.55'

testImplementation 'io.opentelemetry:opentelemetry-api:1.37.0'
testImplementation 'io.opentelemetry:opentelemetry-context:1.37.0'
testImplementation 'io.github.std-uritemplate:std-uritemplate:0.0.57'
implementation 'com.google.code.gson:gson:2.10.1'

implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'

api 'com.squareup.okhttp3:okhttp:4.12.0'
api 'com.azure:azure-core:1.47.0'
api 'com.azure:azure-core:1.48.0'

api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.1.2'
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.1.2'
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.1.2'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.1.2'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.1.2'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.1.2'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.1.2'
api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.1.6'
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.1.6'
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.1.6'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.1.6'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.1.6'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.1.6'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.1.6'
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
<version>1.47.0</version>
<version>1.48.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -53,7 +53,7 @@
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
<version>4.8.3</version>
<version>4.8.4</version>
</dependency>
</dependencies>
</project>
2 changes: 1 addition & 1 deletion src/main/java/com/microsoft/graph/core/CoreConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private CoreConstants() {}
private static class VersionValues {
private static final int MAJOR = 3;
private static final int MINOR = 1;
private static final int PATCH = 7;
private static final int PATCH = 8;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,46 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
Objects.requireNonNull(response);
Objects.requireNonNull(factory);
try (final ResponseBody body = response.body()) {
if (Objects.isNull(body)) {
UploadResult<T> uploadResult = new UploadResult<>();
String contentLengthHeader = response.headers().get("content-length");
// rely on content-type OR content-length headers to determine if response body is empty.
// Response body() may be non-null despite being empty in raw response https://square.github.io/okhttp/3.x/okhttp/okhttp3/Response.html#body--
// content-length header is not always present in Graph responses. Content-type is more reliable
if (Objects.isNull(body)
|| Objects.isNull(body.contentType())
|| (!Objects.isNull(contentLengthHeader) && Integer.parseInt(contentLengthHeader) == 0)
) {
if (response.code() == HttpURLConnection.HTTP_CREATED) {
final String location = response.headers().get("location");
if(!Objects.isNull(location) && !location.isEmpty()) {
uploadResult.location = new URI(location);
return uploadResult;
}
}
throw new ApiException(ErrorConstants.Messages.NO_RESPONSE_FOR_UPLOAD);
}
try(final InputStream in = body.byteStream()){
final String contentType = body.contentType().toString().split(";")[0]; //contentType.toString() returns in format <mediaType>;<charset>, we only want the mediaType.
if(!response.isSuccessful()) {
throw new ApiExceptionBuilder()
.withMessage(ErrorConstants.Codes.GENERAL_EXCEPTION)
.withResponseStatusCode(response.code())
.withResponseHeaders(HeadersCompatibility.getResponseHeaders(response.headers()))
.build();
}
UploadResult<T> uploadResult = new UploadResult<>();
if (response.code() == HttpURLConnection.HTTP_CREATED) {
if (body.contentLength() > 0) {
final ParseNode uploadTypeParseNode = parseNodeFactory.getParseNode(contentType, in);
uploadResult.itemResponse = uploadTypeParseNode.getObjectValue(factory);
}
final String location = response.headers().get("location");
if(!Objects.isNull(location) && !location.isEmpty()) {
uploadResult.location = new URI(location);
}
} else {
boolean canBeParsed = (!Objects.isNull(contentLengthHeader) && Integer.parseInt(contentLengthHeader) > 0) || !Objects.isNull(body.contentType());
String contentType = canBeParsed ? body.contentType().toString().split(";")[0] : null; //contentType.toString() returns in format <mediaType>;<charset>, we only want the mediaType.
if (canBeParsed) {
final ParseNode parseNode = parseNodeFactory.getParseNode(contentType, in);
final UploadSession uploadSession = parseNode.getObjectValue(UploadSession::createFromDiscriminatorValue);
final List<String> nextExpectedRanges = uploadSession.getNextExpectedRanges();
if (!(nextExpectedRanges == null || nextExpectedRanges.isEmpty())) {
uploadResult.uploadSession = uploadSession;
} else {
if (response.code() == HttpURLConnection.HTTP_CREATED) {
uploadResult.itemResponse = parseNode.getObjectValue(factory);
} else {
final UploadSession uploadSession = parseNode.getObjectValue(UploadSession::createFromDiscriminatorValue);
final List<String> nextExpectedRanges = uploadSession.getNextExpectedRanges();
if (!(nextExpectedRanges == null || nextExpectedRanges.isEmpty())) {
uploadResult.uploadSession = uploadSession;
} else {
uploadResult.itemResponse = parseNode.getObjectValue(factory);
}
}
}
return uploadResult;
Expand All @@ -91,6 +101,7 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
throw new RuntimeException(ex);
}
}

}


Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public IUploadSession updateSessionStatus() {
return session;
}
private UploadResult<T> uploadSlice(UploadSliceRequestBuilder<T> uploadSliceRequestBuilder, ArrayList<Throwable> exceptionsList) throws IOException {
byte[] buffer = chunkInputStream(uploadStream,(int) uploadSliceRequestBuilder.getRangeBegin(), (int)uploadSliceRequestBuilder.getRangeLength());
byte[] buffer = chunkInputStream(uploadStream, (int)uploadSliceRequestBuilder.getRangeLength());
ByteArrayInputStream chunkStream = new ByteArrayInputStream(buffer);
try {
return uploadSliceRequestBuilder.put(chunkStream);
Expand Down Expand Up @@ -275,9 +275,9 @@ private long nextSliceSize(long rangeBegin, long rangeEnd) {
long size = rangeEnd - rangeBegin + 1;
return Math.min(size, this.maxSliceSize);
}
private byte[] chunkInputStream(InputStream stream, int begin, int length) throws IOException {
private byte[] chunkInputStream(InputStream stream, int length) throws IOException {
byte[] buffer = new byte[length];
int lengthAssert = stream.read(buffer, begin, length);
int lengthAssert = stream.read(buffer);
assert lengthAssert == length;
return buffer;
}
Expand Down
Loading

0 comments on commit 9ac7e26

Please sign in to comment.