Closed tvhung83 closed 6 years ago
All the user plugins have to change their code in their plugins.
Ah, you're right, but I think users only have to change plugin code if they upgrade version.
Can you clarify the more detailed scenario why we really need this?
This is when readResponse() have temporary issues, such as connector received unexpected response, for example, HTML instead of XML. Or the stream was closed during reading.
I don't think this is a very reasonable change.
I've double checked jetty9x-retryhelper
, they all have throws
during deserialization:
Okay, it sounds possibly reasonable because Jetty93 and Jetty92 are doing similar, but what I'm still not sure is why we need to throw the Exception out of the readResponse
method, not to process the Exception in readResponse
. Can you share the scenario why?
@dmikurube It would make JAXRSResponseReader
complicated unnecessarily, ie. having passing all retry params and manage its own retryExecutor
, while it can just throw the exception and let JAXRSRetryHelper
do its job.
@tvhung83 Can you show that by example code?
@dmikurube which example do you mean? Example of unnecessary complex JAXRSResponseReader
?
Yes, I have no ideas about the "complicated unnecessarily".
Well, I PR to avoid the adhoc workaround, I'm not sure how I can explain it clearer, but I hope below can give you a hint:
throws
:
@Override
public TsResponse readResponse(Response response) throws Exception
{
if (!response.hasEntity()) {
return null;
}
InputStream out = response.readEntity(InputStream.class);
filter.parse(new InputSource(out));
return (TsResponse) unmarshallerHandler.getResult();
}
throws
:
@Override
public TsResponse readResponse(Response response)
{
if (!response.hasEntity()) {
return null;
}
try {
InputStream out = response.readEntity(InputStream.class);
filter.parse(new InputSource(out));
return (TsResponse) unmarshallerHandler.getResult();
}
catch (SAXException | JAXBException | IOException e) {
// retry here, and in order to do that, you will have another `retryExecutor` here
}
}
Thank you for reviewing 🙇 I also missed the need of requester
.
Could you help merge it when you got a chance?
Okay, merging.
We may want the new release to have an updated second level number of the version number since it may break the compatibility. (0.5.0
=> 0.6.0
)
Context
Sometimes, there are exceptions during deserialization HTTP response: stream is closed, wrong expectation, etc.
Sample implementation
Example exceptions
Target
This will allow
retryExecutor
to handle the exception, instead ofJAXRSResponseReader
to catch exception and retry itself.