-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try removing sync stack context flag #34184
Conversation
API change check API changes are not detected in this pull request. |
/azp run java - containerregistry - tests |
/azp run java - monitor - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
1 similar comment
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run java - keyvault - ci |
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
/azp run java - keyvault - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
sdk/core/azure-core/src/main/java/com/azure/core/http/rest/RestProxy.java
Outdated
Show resolved
Hide resolved
@Override | ||
public BinaryData getBodyAsBinaryData() { | ||
BinaryData content = actualResponse.getBodyAsBinaryData(); | ||
doLog(content.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this API override logging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make body logging synchronous: getBodyAsBinaryData
is the only sync way to get the response body and default implementation is async
azure-sdk-for-java/sdk/core/azure-core/src/main/java/com/azure/core/http/HttpResponse.java
Lines 89 to 92 in 1cb5a6a
public BinaryData getBodyAsBinaryData() { | |
Flux<ByteBuffer> body = getBody(); | |
if (body != null) { | |
return BinaryDataHelper.createBinaryData(new FluxByteBufferContent(body)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we eagerly call content.toString()
here? Instead we should consider passing the content
to doLog() method and there, we can use the supplier methods ClientLogger provides to log if logging is enabled - logBuilder.addKeyValue(BODY_KEY, () -> content.toString())
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoggingHttpResponse
is created only if logging at that level is enabled, body logging is enabled and content type is not a stream, so there is no need to do lazy toString
- there are no checks in doLog
method.
Lines 300 to 315 in 4103846
if (!logger.canLogAtLevel(logLevel)) { | |
return response; | |
} | |
LoggingEventBuilder logBuilder = getLogBuilder(logLevel, logger); | |
logContentLength(response, logBuilder); | |
logUrl(loggingOptions, response, logBuilder); | |
logHeaders(logger, response, logBuilder); | |
if (httpLogDetailLevel.shouldLogBody()) { | |
String contentTypeHeader = response.getHeaderValue("Content-Type"); | |
long contentLength = getContentLength(logger, response.getHeaders()); | |
if (shouldBodyBeLogged(contentTypeHeader, contentLength)) { | |
return new LoggingHttpResponse(response, logBuilder, logger, |
/azp run java - keyvault - tests |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes lgtm!
@Override | ||
public BinaryData getBodyAsBinaryData() { | ||
BinaryData content = actualResponse.getBodyAsBinaryData(); | ||
doLog(content.toString()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we eagerly call content.toString()
here? Instead we should consider passing the content
to doLog() method and there, we can use the supplier methods ClientLogger provides to log if logging is enabled - logBuilder.addKeyValue(BODY_KEY, () -> content.toString())
.
No description provided.