Skip to content

Commit b5a0397

Browse files
authored
fix: Propagate IOExceptions in OkHttpFluxRequestBody (#47170)
* fix: Propagate IOExceptions in OkHttpFluxRequestBody * add Checkstyle suppression for ThrowFromClientLoggerCheck
1 parent cb86330 commit b5a0397

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

sdk/core/azure-core-http-okhttp/checkstyle-suppressions.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
<suppressions>
66
<suppress files="com.azure.core.http.okhttp.OkHttpAsyncHttpClientBuilder.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ExternalDependencyExposedCheck" />
77
<suppress files="com.azure.core.http.okhttp.OkHttpAsyncHttpClientBuilder.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ServiceClientBuilderCheck" />
8+
<suppress files="com.azure.core.http.okhttp.implementation.OkHttpFluxRequestBody.java" checks="io.clientcore.linting.extensions.checkstyle.checks.ThrowFromClientLoggerCheck" />
89
</suppressions>

sdk/core/azure-core-http-okhttp/src/main/java/com/azure/core/http/okhttp/implementation/OkHttpFluxRequestBody.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,23 @@ public void writeTo(BufferedSink bufferedSink) throws IOException {
8383
}
8484
}, 1, 1).then();
8585

86-
// The blocking happens on OkHttp thread pool.
87-
if (callTimeoutMillis > 0) {
88-
/*
89-
* Default call timeout (in milliseconds). By default there is no timeout for complete calls, but
90-
* there is for the connection, write, and read actions within a call.
91-
*/
92-
requestSendMono.block(Duration.ofMillis(callTimeoutMillis));
93-
} else {
94-
requestSendMono.block();
86+
try {
87+
// The blocking happens on OkHttp thread pool.
88+
if (callTimeoutMillis > 0) {
89+
/*
90+
* Default call timeout (in milliseconds). By default there is no timeout for complete calls, but
91+
* there is for the connection, write, and read actions within a call.
92+
*/
93+
requestSendMono.block(Duration.ofMillis(callTimeoutMillis));
94+
} else {
95+
requestSendMono.block();
96+
}
97+
} catch (RuntimeException e) {
98+
if (e.getCause() instanceof IOException) {
99+
throw (IOException) e.getCause();
100+
} else {
101+
throw e;
102+
}
95103
}
96104
} else {
97105
// Prevent OkHttp from potentially re-sending non-repeatable body outside of retry policies.

0 commit comments

Comments
 (0)