-
Notifications
You must be signed in to change notification settings - Fork 369
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
Generally processing of exception with serial execution. #848
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,19 +81,39 @@ protected final void setLayers(final Layer specificLayers[]) { | |
@Override | ||
public void sendRequest(final Exchange exchange, final Request request) { | ||
// delegate to top | ||
top.sendRequest(exchange, request); | ||
try { | ||
top.sendRequest(exchange, request); | ||
} catch (RuntimeException ex) { | ||
request.setSendError(ex); | ||
} | ||
} | ||
|
||
@Override | ||
public void sendResponse(final Exchange exchange, final Response response) { | ||
// delegate to top | ||
top.sendResponse(exchange, response); | ||
try { | ||
if (exchange.getRequest().getOptions().hasObserve()) { | ||
// observe- or cancel-observe-requests may have | ||
// multiple responses. | ||
// when observes are finished, the last response has | ||
// no longer an observe option. Therefore check the | ||
// request for it. | ||
exchange.retransmitResponse(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is totally out of topic because you just move this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I move it into the "try - catch". The CoapEndpoint, for some reasons, use
In my very first variant, I used two try-catch, but moving it reduces that. And moving the if into the try-catch makes it somehow more complete. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The question was more about the code itself (exchange.retransmitResponse) instead of the move. (that's why I notice that my question was totally out of topic :p) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. A server-side-observe-exchange gets completed with the current response. Before sending the next notify, the Exchange must be prepared to accept that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok It's a bit clearer At first sight, I was confused because I thought that |
||
top.sendResponse(exchange, response); | ||
} catch (RuntimeException ex) { | ||
response.setSendError(ex); | ||
} | ||
} | ||
|
||
@Override | ||
public void sendEmptyMessage(final Exchange exchange, final EmptyMessage message) { | ||
// delegate to top | ||
top.sendEmptyMessage(exchange, message); | ||
try { | ||
top.sendEmptyMessage(exchange, message); | ||
} catch (RuntimeException ex) { | ||
message.setSendError(ex); | ||
} | ||
} | ||
|
||
@Override | ||
|
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'm not sure if sending RST is a good idea... 🤔
Did you consider to send an Internal Server Error Response ?
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 added those try-catch, because without, nothing happens.
For a "Internal Server Error Response" I would try to create more speaky ones.
If a Exception reaches that, I hope the log will help to fix the bug or create a speaky response.