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

Do not produce an empty response when ServiceCodec raises an exception #200

Merged

Conversation

trustin
Copy link
Member

@trustin trustin commented Jul 11, 2016

Motivation:

When a ServiceCodec.decodeRequest() raises an exception,
HttpServerHandler will close the connection immediately without sending
anything. Instead, the server should send a '400 Bad Request' response.

Modifications:

  • HttpServerHandler now catches an exception raised by
    ServiceCodec.decodeRequest() and responds with a '400 Bad Request'
    response.
  • ThriftServiceCodec.decodeRequest() now catches an exception raised by
    TProtocol.readMessageBegin() and returns a failed DecoderResult
    instead of raising an exception.

Result:

  • Armeria server sends a 400 Bad Request even if
    ServiceCodec.decodeRequest() raises an exception.
  • ThriftServiceCodec.decodeRequest() deals with a bad request better.

@trustin trustin added the defect label Jul 11, 2016
@trustin trustin added this to the 0.20.2.Final milestone Jul 11, 2016
hostname, path, mappedPath, req.content(), req, promise);
} catch (Exception e) {
logger.warn("{} Unexpected exception from a decoder:", ctx.channel(), e);
respond(ctx, reqSeq, req, HttpResponseStatus.BAD_REQUEST);
Copy link
Contributor

@jongyeol jongyeol Jul 11, 2016

Choose a reason for hiding this comment

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

How about appending e as 5th parameter?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea. Fixed.

Motivation:

When a ServiceCodec.decodeRequest() raises an exception,
HttpServerHandler will close the connection immediately without sending
anything. Instead, the server should send a '400 Bad Request' response.

Modifications:

- HttpServerHandler now catches an exception raised by
  ServiceCodec.decodeRequest() and responds with a '400 Bad Request'
  response.
- ThriftServiceCodec.decodeRequest() now catches an exception raised by
  TProtocol.readMessageBegin() and returns a failed DecoderResult
  instead of raising an exception.

Result:

- Armeria server sends a 400 Bad Request even if
  ServiceCodec.decodeRequest() raises an exception.
- ThriftServiceCodec.decodeRequest() deals with a bad request better.
@trustin trustin force-pushed the fix_empty_response_on_decoder_exception branch from 9a1af81 to 974ed33 Compare July 11, 2016 05:03
@jongyeol
Copy link
Contributor

LGTM

@jongyeol jongyeol merged commit de1b71f into line:master Jul 11, 2016
@trustin trustin deleted the fix_empty_response_on_decoder_exception branch July 11, 2016 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants