-
-
Notifications
You must be signed in to change notification settings - Fork 428
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
Prevent errors in log when client closes the HTTP connection #2655
Conversation
// we catch this exception to avoid confusion errors in the log file, since this is not any error situation | ||
// see https://github.com/openhab/openhab-distro/issues/1188 | ||
logger.debug("Failed writing HTTP response, since other side closed the connection"); | ||
// Returning null results in a Response.Status.NO_CONTENT 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.
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.
Returning null sounds just fine. In any case, the client won't receive what we return at all and null
seems to best indicate that there's really nothing to return from our side.
// see https://github.com/openhab/openhab-distro/issues/1188 | ||
logger.debug("Failed writing HTTP response, since other side closed the connection"); | ||
// Returning null results in a Response.Status.NO_CONTENT response. | ||
return 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.
Another solution:
return null; | |
return Response.noContent().build(); |
Or:
return null; | |
return Response.serverError().build(); |
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
13c5f07
to
df61269
Compare
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 haven't tested it, but the code looks good and I would expect it to solve the issue.
// we catch this exception to avoid confusion errors in the log file, since this is not any error situation | ||
// see https://github.com/openhab/openhab-distro/issues/1188 | ||
logger.debug("Failed writing HTTP response, since other side closed the connection"); | ||
// Returning null results in a Response.Status.NO_CONTENT 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.
Returning null sounds just fine. In any case, the client won't receive what we return at all and null
seems to best indicate that there's really nothing to return from our side.
See openhab/openhab-distro#1188 (comment) and #2049.
@openhab/core-maintainers Please tell me your opinion.
Signed-off-by: Christoph Weitkamp github@christophweitkamp.de