Skip to content

Commit 26c3d3a

Browse files
committed
Fix NPE
1 parent 4d07844 commit 26c3d3a

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

client-runtime/src/main/java/com/microsoft/rest/ServiceResponseBuilder.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ public <THeader> ServiceResponseWithHeaders<T, THeader> buildWithHeaders(Respons
214214
THeader headers = mapperAdapter.deserialize(
215215
mapperAdapter.serialize(response.headers()),
216216
headerType);
217-
response.errorBody().close();
218217
return new ServiceResponseWithHeaders<>(bodyResponse.getBody(), headers, bodyResponse.getResponse());
219218
}
220219

@@ -240,7 +239,6 @@ public <THeader> ServiceResponseWithHeaders<T, THeader> buildEmptyWithHeaders(Re
240239
THeader headers = mapperAdapter.deserialize(
241240
mapperAdapter.serialize(response.headers()),
242241
headerType);
243-
response.errorBody().close();
244242
return new ServiceResponseWithHeaders<>(headers, bodyResponse.getHeadResponse());
245243
}
246244

client-runtime/src/main/java/com/microsoft/rest/retry/RetryHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ public Response intercept(Chain chain) throws IOException {
7171
int tryCount = 0;
7272
while (retryStrategy.shouldRetry(tryCount, response)) {
7373
tryCount++;
74-
response.body().close();
74+
if (response.body() != null) {
75+
response.body().close();
76+
}
7577
// retry the request
7678
response = chain.proceed(request);
7779
}

0 commit comments

Comments
 (0)