Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
15 changes: 7 additions & 8 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,18 @@ dependencies {
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:3.0.0'

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

api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.1.4'
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.1.4'
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.1.4'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.1.4'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.1.4'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.1.4'
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.1.4'
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'
}
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