-
Notifications
You must be signed in to change notification settings - Fork 215
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
Conversation
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()); |
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.
im not sure "cuase()" will return an expcetion always in this branch, it may potentially throw NPE...
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.
@jaimecasero
Seems like theres only two places where DownloaderResponse
is instantiated, so it doesnt look like anyone every passes a null to exception.
Line 187 in 007020d
response = new DownloaderResponse(exception, "Problem while trying to download RCML"); |
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.
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...
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.
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.
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.
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(); |
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.
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()? |
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.
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...
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 remove the TODO?
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.
i would certainly remvoe the TODO here
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.
DONE
f76f9fb
to
1d52e2e
Compare
@jaimecasero @FerUy Please have a look, apparently the mistake i made before was not moving the
get()
into thesucceeded()
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