GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Correctly handle the case when converting of value fails and return n… by normanmaurer · Pull Request #7715 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented Feb 13, 2018

Copy link
Copy Markdown
Member

…ull or default value.

Motivation:

Headers.get* methods should not throw an exception but return null or the default value if converting of the value fails.

Modifications:

  • Correctly handle the case when ValueConverter throws an Exception.
  • Add testcase.

Result:

Fixes [#7710].

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer
normanmaurer requested review from Scottmitch, carl-mastrangelo and ejona86 February 13, 2018 08:13
@normanmaurer normanmaurer mentioned this pull request Feb 13, 2018
DefaultHeaders does not correctly implement interface #7710
Closed
@normanmaurer normanmaurer self-assigned this Feb 13, 2018
@normanmaurer normanmaurer added the defect label Feb 13, 2018
@normanmaurer normanmaurer added this to the 4.1.22.Final milestone Feb 13, 2018
@normanmaurer
normanmaurer requested a review from trustin February 13, 2018 08:59
ejona86
ejona86 approved these changes Feb 13, 2018
View reviewed changes
Comment thread codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java Outdated
return v != null ? valueConverter.convertToBoolean(v) : null;
try {
return v != null ? valueConverter.convertToBoolean(v) : null;
} catch (Exception ignore) {

@ejona86 ejona86 Feb 13, 2018

Copy link
Copy Markdown
Member

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.

nit: RuntimeException for clarity, although it is equivalent to what's here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Feb 13, 2018

Copy link
Copy Markdown
Member Author

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.

@ejona86 We are talking about all the catch correct ? If so I think that makes sense @carl-mastrangelo @Scottmitch WDYT ?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ejona86 ejona86 Feb 13, 2018

Copy link
Copy Markdown
Member

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.

Yeah, I was talking about all of them

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Scottmitch Scottmitch Feb 13, 2018

Copy link
Copy Markdown
Member

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.

RuntimeException sgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jkinkead
jkinkead reviewed Feb 13, 2018
View reviewed changes
Comment thread codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java
V v = get(name);
return v != null ? valueConverter.convertToBoolean(v) : null;
try {
return v != null ? valueConverter.convertToBoolean(v) : null;

@jkinkead jkinkead Feb 13, 2018

Copy link
Copy Markdown

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 is another bug here that I haven't filed: convertToBoolean has different behavior for AsciiString header values than for other CharSequence values.

AsciiString uses this null-byte-check conversion, whereas other strings use Boolean.parseBoolean, which treats only strings matching "true" as truthy (case-insensitive).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Feb 13, 2018

Copy link
Copy Markdown
Member Author

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.

Please fill another bug or do a or to fix it

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@jkinkead jkinkead Feb 13, 2018

Copy link
Copy Markdown

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, issue #7717 . Thanks!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer
Correctly handle the case when converting of value fails and return n…
5f4526d
…ull or default value.

Motivation:

Headers.get* methods should not throw an exception but return null or the default value if converting of the value fails.

Modifications:

- Correctly handle the case when ValueConverter throws an Exception.
- Add testcase.

Result:

Fixes [#7710].
@normanmaurer
normanmaurer force-pushed the default_http_header_convert_fix branch from af19e1b to 5f4526d Compare February 13, 2018 19:17
@normanmaurer

normanmaurer commented Feb 13, 2018

Copy link
Copy Markdown
Member Author

@ejona86 @Scottmitch addressed PTAL again

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ejona86
ejona86 approved these changes Feb 13, 2018
View reviewed changes
@normanmaurer

normanmaurer commented Feb 14, 2018

Copy link
Copy Markdown
Member Author

Cherry-picked into 4.1 (02b7507)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer closed this Feb 14, 2018
@normanmaurer
normanmaurer deleted the default_http_header_convert_fix branch February 14, 2018 07:36
@Scottmitch

Scottmitch commented Feb 15, 2018

Copy link
Copy Markdown
Member

lgtm

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ejona86 ejona86 ejona86 approved these changes
@Scottmitch Scottmitch Awaiting requested review from Scottmitch
@carl-mastrangelo carl-mastrangelo Awaiting requested review from carl-mastrangelo
@trustin trustin Awaiting requested review from trustin
+1 more reviewer
@jkinkead jkinkead jkinkead left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@normanmaurer normanmaurer

Labels

defect

Projects

None yet

Milestone

4.1.22.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@normanmaurer @Scottmitch @jkinkead @ejona86
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.