Skip to content

Commit 9ac7e26

Browse files
authored
Merge pull request #1582 from microsoftgraph/dev
lfu fix release
2 parents cb2c3d9 + 0f88740 commit 9ac7e26

File tree

12 files changed

+118
-70
lines changed

12 files changed

+118
-70
lines changed

.github/workflows/api-level-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
distribution: 'temurin'
1818
java-version: 20
1919
- name: Setup Android SDK
20-
uses: android-actions/[email protected].0
20+
uses: android-actions/[email protected].1
2121
- name: Add execution right to the script
2222
run: chmod +x gradlew
2323
working-directory: ./android

.github/workflows/build-and-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
with:
112112
tag: ${{ steps.GetVersion.outputs.tag }}
113113
- name: Queue Git Release
114-
uses: benc-uk/workflow-dispatch@v121
114+
uses: benc-uk/workflow-dispatch@v1
115115
with:
116116
workflow: Git Release
117117
token: ${{ secrets.PERSONAL_TOKEN }}

CHANGELOG.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
### Changed
1313

14+
## [3.1.8]
15+
16+
### Added
17+
18+
### Changed
19+
- Changed chunkInputStream method in LargeFileUploadTask to resolve IndexOutOfBoundsException when uploading large files
20+
- Fix Large File Upload bug where exception was thrown for completed successful uploads
21+
1422
## [3.1.7] - 2024-03-28
1523

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

6270
- Version bump for Java SDK GA release.
63-
- Bumps Kiota-Java abstractions, authentication, http, and serialization components for Java SDK 6.1.0 release.
71+
- Bumps Kiota-Java abstractions, authentication, http, and serialization components for Java SDK 6.1.0 release.
6472

6573
## [3.0.12] - 2023-12-15
6674

67-
### Fixed
75+
### Fixed
6876

69-
- 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)
77+
- 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)
7078

7179
## [3.0.11] - 2023-12-08
7280

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

7886
## [3.0.10] - 2023-11-27
7987

80-
### Changed
88+
### Changed
8189

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

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

101109
### Removed
102110

103-
- Removes 'SuppressFBWarnings' annotations and dependency.
111+
- Removes 'SuppressFBWarnings' annotations and dependency.
104112

105113
## [3.0.7] - 2023-07-20
106114

107115
### Added
108116

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

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

124132
## [3.0.4] - 2023-05-03
125133

126-
### Added
127-
128-
- Added LargeFileUploadTask functionality for kiota generated service libraries.
134+
### Added
135+
136+
- Added LargeFileUploadTask functionality for kiota generated service libraries.
129137

130-
### Fixed
138+
### Fixed
131139

132140
- 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)
133141

@@ -171,7 +179,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
171179
private OkHttpClient createClient(@Nonnull final IAuthenticationProvider auth) {
172180
return HttpClients.createDefault(auth);
173181
}
174-
182+
175183
// then create the GraphServiceClient
176184
IAuthenticationProvider authenticationProvider = ...;
177185
GraphServiceClient
@@ -183,16 +191,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
183191

184192
## [2.0.20] - 2023-10-23
185193

186-
### Changed
194+
### Changed
187195

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

190198
## [2.0.19] - 2023-06-20
191199

192200
### Changed
193201

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

197205
## [2.0.18] - 2023-04-06
198206

android/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ buildscript {
55
}
66

77
dependencies {
8-
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.16.2"
9-
classpath "com.android.tools.build:gradle:8.3.1"
8+
classpath "com.gradle:gradle-enterprise-gradle-plugin:3.17.2"
9+
classpath "com.android.tools.build:gradle:8.3.2"
1010
classpath "com.github.ben-manes:gradle-versions-plugin:0.51.0"
1111
}
1212
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'maven-publish'
66
id 'signing'
77
id 'jacoco'
8-
id 'com.github.spotbugs' version '6.0.9'
8+
id 'com.github.spotbugs' version '6.0.12'
99
id "org.sonarqube" version "5.0.0.4638"
1010
}
1111

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ mavenGroupId = com.microsoft.graph
2525
mavenArtifactId = microsoft-graph-core
2626
mavenMajorVersion = 3
2727
mavenMinorVersion = 1
28-
mavenPatchVersion = 7
28+
mavenPatchVersion = 8
2929
mavenArtifactSuffix =
3030

3131
#These values are used to run functional tests

gradle/dependencies.gradle

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,21 @@ dependencies {
44
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2'
55
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2'
66
testImplementation 'org.mockito:mockito-inline:5.2.0'
7-
testImplementation 'io.opentelemetry:opentelemetry-api:1.36.0'
8-
testImplementation 'io.opentelemetry:opentelemetry-context:1.36.0'
9-
testImplementation 'io.github.std-uritemplate:std-uritemplate:0.0.55'
10-
7+
testImplementation 'io.opentelemetry:opentelemetry-api:1.37.0'
8+
testImplementation 'io.opentelemetry:opentelemetry-context:1.37.0'
9+
testImplementation 'io.github.std-uritemplate:std-uritemplate:0.0.57'
1110
implementation 'com.google.code.gson:gson:2.10.1'
1211

13-
implementation 'jakarta.annotation:jakarta.annotation-api:2.1.1'
12+
implementation 'jakarta.annotation:jakarta.annotation-api:3.0.0'
1413

1514
api 'com.squareup.okhttp3:okhttp:4.12.0'
16-
api 'com.azure:azure-core:1.47.0'
15+
api 'com.azure:azure-core:1.48.0'
1716

18-
api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.1.2'
19-
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.1.2'
20-
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.1.2'
21-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.1.2'
22-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.1.2'
23-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.1.2'
24-
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.1.2'
17+
api 'com.microsoft.kiota:microsoft-kiota-abstractions:1.1.6'
18+
implementation 'com.microsoft.kiota:microsoft-kiota-authentication-azure:1.1.6'
19+
implementation 'com.microsoft.kiota:microsoft-kiota-http-okHttp:1.1.6'
20+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-json:1.1.6'
21+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-text:1.1.6'
22+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-form:1.1.6'
23+
implementation 'com.microsoft.kiota:microsoft-kiota-serialization-multipart:1.1.6'
2524
}

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.azure</groupId>
3232
<artifactId>azure-core</artifactId>
33-
<version>1.47.0</version>
33+
<version>1.48.0</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>org.junit.jupiter</groupId>
@@ -53,7 +53,7 @@
5353
<dependency>
5454
<groupId>com.github.spotbugs</groupId>
5555
<artifactId>spotbugs-annotations</artifactId>
56-
<version>4.8.3</version>
56+
<version>4.8.4</version>
5757
</dependency>
5858
</dependencies>
5959
</project>

src/main/java/com/microsoft/graph/core/CoreConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private CoreConstants() {}
1414
private static class VersionValues {
1515
private static final int MAJOR = 3;
1616
private static final int MINOR = 1;
17-
private static final int PATCH = 7;
17+
private static final int PATCH = 8;
1818
}
1919

2020
/**

src/main/java/com/microsoft/graph/core/requests/upload/UploadResponseHandler.java

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,46 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
5252
Objects.requireNonNull(response);
5353
Objects.requireNonNull(factory);
5454
try (final ResponseBody body = response.body()) {
55-
if (Objects.isNull(body)) {
55+
UploadResult<T> uploadResult = new UploadResult<>();
56+
String contentLengthHeader = response.headers().get("content-length");
57+
// rely on content-type OR content-length headers to determine if response body is empty.
58+
// Response body() may be non-null despite being empty in raw response https://square.github.io/okhttp/3.x/okhttp/okhttp3/Response.html#body--
59+
// content-length header is not always present in Graph responses. Content-type is more reliable
60+
if (Objects.isNull(body)
61+
|| Objects.isNull(body.contentType())
62+
|| (!Objects.isNull(contentLengthHeader) && Integer.parseInt(contentLengthHeader) == 0)
63+
) {
64+
if (response.code() == HttpURLConnection.HTTP_CREATED) {
65+
final String location = response.headers().get("location");
66+
if(!Objects.isNull(location) && !location.isEmpty()) {
67+
uploadResult.location = new URI(location);
68+
return uploadResult;
69+
}
70+
}
5671
throw new ApiException(ErrorConstants.Messages.NO_RESPONSE_FOR_UPLOAD);
5772
}
5873
try(final InputStream in = body.byteStream()){
59-
final String contentType = body.contentType().toString().split(";")[0]; //contentType.toString() returns in format <mediaType>;<charset>, we only want the mediaType.
6074
if(!response.isSuccessful()) {
6175
throw new ApiExceptionBuilder()
6276
.withMessage(ErrorConstants.Codes.GENERAL_EXCEPTION)
6377
.withResponseStatusCode(response.code())
6478
.withResponseHeaders(HeadersCompatibility.getResponseHeaders(response.headers()))
6579
.build();
6680
}
67-
UploadResult<T> uploadResult = new UploadResult<>();
68-
if (response.code() == HttpURLConnection.HTTP_CREATED) {
69-
if (body.contentLength() > 0) {
70-
final ParseNode uploadTypeParseNode = parseNodeFactory.getParseNode(contentType, in);
71-
uploadResult.itemResponse = uploadTypeParseNode.getObjectValue(factory);
72-
}
73-
final String location = response.headers().get("location");
74-
if(!Objects.isNull(location) && !location.isEmpty()) {
75-
uploadResult.location = new URI(location);
76-
}
77-
} else {
81+
boolean canBeParsed = (!Objects.isNull(contentLengthHeader) && Integer.parseInt(contentLengthHeader) > 0) || !Objects.isNull(body.contentType());
82+
String contentType = canBeParsed ? body.contentType().toString().split(";")[0] : null; //contentType.toString() returns in format <mediaType>;<charset>, we only want the mediaType.
83+
if (canBeParsed) {
7884
final ParseNode parseNode = parseNodeFactory.getParseNode(contentType, in);
79-
final UploadSession uploadSession = parseNode.getObjectValue(UploadSession::createFromDiscriminatorValue);
80-
final List<String> nextExpectedRanges = uploadSession.getNextExpectedRanges();
81-
if (!(nextExpectedRanges == null || nextExpectedRanges.isEmpty())) {
82-
uploadResult.uploadSession = uploadSession;
83-
} else {
85+
if (response.code() == HttpURLConnection.HTTP_CREATED) {
8486
uploadResult.itemResponse = parseNode.getObjectValue(factory);
87+
} else {
88+
final UploadSession uploadSession = parseNode.getObjectValue(UploadSession::createFromDiscriminatorValue);
89+
final List<String> nextExpectedRanges = uploadSession.getNextExpectedRanges();
90+
if (!(nextExpectedRanges == null || nextExpectedRanges.isEmpty())) {
91+
uploadResult.uploadSession = uploadSession;
92+
} else {
93+
uploadResult.itemResponse = parseNode.getObjectValue(factory);
94+
}
8595
}
8696
}
8797
return uploadResult;
@@ -91,6 +101,7 @@ public <T extends Parsable> UploadResult<T> handleResponse(@Nonnull final Respon
91101
throw new RuntimeException(ex);
92102
}
93103
}
104+
94105
}
95106

96107

0 commit comments

Comments
 (0)