Skip to content
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

Serialize and deserialize azure core exception type. #5159

Closed
wants to merge 12 commits into from

Conversation

sima-zhu
Copy link
Contributor

@sima-zhu sima-zhu commented Aug 29, 2019

Summary:

  1. The PR is to generic exception type and deserialize it for client library tests.
  2. Remove the stack trace from record json files.
  3. Added the exception to storage blob, uncommon related tests and fix bugs in storage.

Problem to solve:
Currently, playback can only deserialize specific exception type using switch case. Moreover, the exception must have default constructor. Try to generic the process so people do not need to continue adding different exceptions. Also, the UnexpectedLengthException asks value constructor, which is also a shortage for the playback.

Issue related:
#4193

@sima-zhu sima-zhu requested a review from alzimmermsft August 29, 2019 22:19
@JonathanGiles
Copy link
Member

Can you please update the description to explain what this PR is attempting to achieve, and why. Is there an issue filed that describes this? Please provide more context.

Copy link
Member

@JonathanGiles JonathanGiles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NetworkCallError needs careful consideration before this should be merged.

throw logger.logExceptionAsWarning(Exceptions.propagate(networkCallRecord.exception().get()));
}

constructExceptionType(networkCallRecord);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should change this. At present the constructExceptionType call is odd, as it may throw an exception but it won't if the networkCallRecord.exception() is null. You should reinstitute the if block you removed, and then make constructExceptionType return an exception that is then definitively thrown.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the step only takes affect when exception is not null.
Will add a checking before calling the method.
Thanks for catching this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My suggestion and what you implemented are slightly different. Please re-read and clarify with me if necessary.


package com.azure.core.implementation.exception;

public class UnexpectedLengthException extends IllegalStateException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are making this class non-public API. Do you ever document anywhere in the storage APIs that this is thrown in certain situations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I will update the API which will throw the exception. This is not intended to use by client. It is for http request validation.

Mono<Response<BlockBlobItem>> upload = blockBlobAsyncClient
.uploadWithResponse(fbb.subscribeOn(Schedulers.elastic()), length, headers, metadata, accessConditions, context);
.uploadWithResponse(fbb, length, headers, metadata, accessConditions, context);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we want to remove the subscribeOn here?

@sima-zhu
Copy link
Contributor Author

sima-zhu commented Sep 3, 2019

Close it as this is not the approach we take

@sima-zhu sima-zhu closed this Sep 3, 2019
@sima-zhu sima-zhu deleted the azure-core-test branch September 3, 2019 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants