Skip to content

Commit 21403ea

Browse files
committed
- aligns manually edited files with v1
1 parent 67fc1c6 commit 21403ea

7 files changed

Lines changed: 17 additions & 31 deletions

File tree

src/main/java/com/microsoft/graph/concurrency/ChunkedUploadResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* @param <UploadType> the expected uploaded item
4646
*/
4747
public class ChunkedUploadResponseHandler<UploadType>
48-
implements IStatefulResponseHandler<ChunkedUploadResult, UploadType> {
48+
implements IStatefulResponseHandler<ChunkedUploadResult<UploadType>, UploadType> {
4949
/**
5050
* The expected deserialized upload type
5151
*/

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,5 @@ private Constants() {
2828
public static final String APPID = "app-id";
2929
public static final String USERNAME = "user@email.com";
3030
public static final String PASSWORD = "password";
31-
public static final String VERSION_NAME = "1.6.0";
31+
public static final String VERSION_NAME = "1.9.0";
3232
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public IShouldRetry getShouldRetry() {
164164
* @param maxRetries Max retries for a request
165165
*/
166166
public void setMaxRetries(int maxRetries) {
167-
this.maxRedirects = maxRedirects;
167+
this.maxRetries = maxRetries;
168168
}
169169

170170
/**

src/main/java/com/microsoft/graph/http/CoreHttpProvider.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public Request authenticateRequest(Request request) {
269269
.tag(RetryOptions.class, retryOptions);
270270

271271
String contenttype = null;
272+
Response response = null;
272273

273274
try {
274275
logger.logDebug("Request Method " + request.getHttpMethod().toString());
@@ -353,7 +354,7 @@ public MediaType contentType() {
353354
coreHttpRequest = corehttpRequestBuilder.build();
354355

355356
// Call being executed
356-
Response response = corehttpClient.newCall(coreHttpRequest).execute();
357+
response = corehttpClient.newCall(coreHttpRequest).execute();
357358

358359
if (handler != null) {
359360
handler.configConnection(response);
@@ -401,12 +402,13 @@ public MediaType contentType() {
401402
return (Result) handleBinaryStream(in);
402403
}
403404
} finally {
404-
if (!isBinaryStreamInput && in != null) {
405+
if (!isBinaryStreamInput) {
405406
try{
406-
in.close();
407+
if (in != null) in.close();
407408
}catch(IOException e) {
408409
logger.logError(e.getMessage(), e);
409410
}
411+
if (response != null) response.close();
410412
}
411413
}
412414
} catch (final GraphServiceException ex) {

src/main/java/com/microsoft/graph/http/GraphServiceException.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package com.microsoft.graph.http;
2424

2525
import java.io.IOException;
26+
import java.io.InputStream;
2627
import java.util.LinkedList;
2728
import java.util.List;
2829
import java.util.Locale;
@@ -38,6 +39,7 @@
3839
import com.microsoft.graph.serializer.ISerializer;
3940

4041
import okhttp3.Response;
42+
import static okhttp3.internal.Util.closeQuietly;
4143

4244
/**
4345
* An exception from the Graph service
@@ -416,8 +418,12 @@ public static <T> GraphServiceException createFromConnection(final IHttpRequest
416418

417419
final String responseMessage = response.message();
418420
String rawOutput = "{}";
419-
if(response.body().byteStream() != null) {
420-
rawOutput = DefaultHttpProvider.streamToString(response.body().byteStream());
421+
422+
InputStream is = response.body().byteStream();
423+
try {
424+
rawOutput = DefaultHttpProvider.streamToString(is);
425+
} finally {
426+
closeQuietly(is);
421427
}
422428
GraphErrorResponse error;
423429
try {

src/main/java/com/microsoft/graph/serializer/DefaultSerializer.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,9 @@ else if (fieldObject != null && fieldObject instanceof IJsonBackedObject) {
256256
*/
257257
private void addAdditionalDataToJson(AdditionalDataManager additionalDataManager, JsonObject jsonNode) {
258258
for (Map.Entry<String, JsonElement> entry : additionalDataManager.entrySet()) {
259-
if (!fieldIsOdataTransient(entry)) {
260-
jsonNode.add(
261-
entry.getKey(),
262-
entry.getValue()
263-
);
264-
}
259+
jsonNode.add(entry.getKey(), entry.getValue());
265260
}
266261
}
267-
268-
private boolean fieldIsOdataTransient(Map.Entry<String, JsonElement> entry) {
269-
return (entry.getKey().startsWith("@") && entry.getKey() != "@odata.type");
270-
}
271262

272263
/**
273264
* Get the derived class for the given JSON object

src/test/java/com/microsoft/graph/serializer/AdditionalDataTests.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,6 @@ public void testChildAdditionalData() {
5656
assertEquals("{\"manager\":{\"id\":\"1\",\"additionalData\":\"additionalValue\"},\"id\":\"2\"}", serializedObject);
5757
}
5858

59-
@Test
60-
public void testSkipTransientData() {
61-
Entity entity = new Entity();
62-
entity.id = "1";
63-
64-
entity.additionalDataManager().put("@odata.type", new JsonPrimitive("entity"));
65-
entity.additionalDataManager().put("@odata.nextLink", new JsonPrimitive("1"));
66-
67-
String serializedObject = serializer.serializeObject(entity);
68-
69-
assertEquals("{\"id\":\"1\",\"@odata.type\":\"entity\"}", serializedObject);
70-
}
71-
7259
@Test
7360
public void testHashMapChildAnnotationData() {
7461
PlannerTask task = new PlannerTask();

0 commit comments

Comments
 (0)