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

Issue 2521: Move DownloaderResponse access after succeeded() check #2549

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

abdulazizali77
Copy link
Contributor

@abdulazizali77 abdulazizali77 commented Oct 6, 2017

@jaimecasero @FerUy Please have a look, apparently the mistake i made before was not moving the get() into the succeeded() block.
Have added extra logging, advise if overkill.

There is already preexisting TechDebts for UssdInterpreter so we will address further possible design issues there separately
#2444
#2443

@FerUy
Copy link

FerUy commented Oct 6, 2017

Looks good to me @abdulazizali77 (and not risky at all), @jaimecasero do you agree?

if(HttpStatus.SC_OK == sc){
fsm.transition(message, ready);
} else if (HttpStatus.SC_NOT_FOUND == sc){
fsm.transition(message, notFound);
}
} else {
if (logger.isDebugEnabled()) {
logger.debug("Rcml DownloaderResponse error : " + response.error()
+ ", cause=" + response.cause().getMessage());
Copy link
Contributor

Choose a reason for hiding this comment

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

im not sure "cuase()" will return an expcetion always in this branch, it may potentially throw NPE...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jaimecasero
Seems like theres only two places where DownloaderResponse is instantiated, so it doesnt look like anyone every passes a null to exception.

response = new DownloaderResponse(exception, "Problem while trying to download RCML");

Copy link
Contributor

Choose a reason for hiding this comment

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

im talkign abotu this expression "response.cause().getMessage()", and particularly how "response.cause()" may lead to null, not "response" object itself. I just dont want to chagne an NPE for other...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What i pointed out was there does not seem to be any other Download failure instance where we instantiate the DownloaderResponse with null exception instead.
Line 187 is the only DownloaderResponse failure instance, so when it fails exception is always set. Hence there is no failure case where DownloaderResponse.cause() is null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made an inline null check, dont really like that idiom for sure, but maybe easiest compromise. Advise if you think we should do away with it.

}
//FIXME: what if these ifblocks arent in downloadingRcml?
if (response.succeeded()) {
int sc = response.get().getStatusCode();
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be safe now, as i suggested...

if (downloadingRcml.equals(state) && fallbackUrl!=null) {
fsm.transition(message, downloadingFallbackRcml);
} else {
//TODO: should we rethrow response.error()?
Copy link
Contributor

Choose a reason for hiding this comment

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

exception handling is not always rethrowing... In this case we are both sending BYE potentially,and letting the FSM transition, so i would say no rethrow in this case...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

should we remove the TODO?

Copy link
Contributor

Choose a reason for hiding this comment

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

i would certainly remvoe the TODO here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DONE

@jaimecasero jaimecasero merged commit 9ed6a3c into master Oct 9, 2017
@abdulazizali77 abdulazizali77 deleted the abdulazizali-BUG2521 branch October 10, 2017 19:59
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