Skip to content

Conversation

@jaikiran
Copy link
Member

@jaikiran jaikiran commented Nov 21, 2022

Can I please get a review for this small change which addresses https://bugs.openjdk.org/browse/JDK-8297211?
The change checks if the content-length header value is present before parsing it into a Long value. The commit also now catches the more specific NumberFormatException instead of a general Exception. Given the context of the code, I believe this change in the exception type in the catch block should be fine.

No new test has been introduced given the nature of this change. I have triggered existing tests to verify no unexpected regressions show up.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-length in response

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/11258/head:pull/11258
$ git checkout pull/11258

Update a local copy of the PR:
$ git checkout pull/11258
$ git pull https://git.openjdk.org/jdk pull/11258/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11258

View PR using the GUI difftool:
$ git pr show -t 11258

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/11258.diff

…tOutputStream0 when no content-lenght in response
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 21, 2022

👋 Welcome back jpai! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 21, 2022
@openjdk
Copy link

openjdk bot commented Nov 21, 2022

@jaikiran The following label will be automatically applied to this pull request:

  • net

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the net net-dev@openjdk.org label Nov 21, 2022
@mlbridge
Copy link

mlbridge bot commented Nov 21, 2022

Webrevs

@jaikiran jaikiran changed the title 8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-lenght in response 8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-length in response Nov 21, 2022
Copy link
Member

@simonis simonis left a comment

Choose a reason for hiding this comment

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

Your fix looks good, but there are two other places in the file with the same pattern in getHeaderFieldDate() and getHeaderFieldLong(). Can you please fix them as well?

@jaikiran
Copy link
Member Author

Hello Volker, I have updated to PR to include those 3 places as well (there was one more in addition to the couple you noted).

Copy link
Member

@eastig eastig left a comment

Choose a reason for hiding this comment

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

lgtm

if (value != null) {
try {
return Date.parse(value);
} catch (NumberFormatException e) { }
Copy link
Member

Choose a reason for hiding this comment

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

(not a reviewer) I think NumberFormatException isn't sufficient here. Date.parse might throw an IllegalArgumentException.

Copy link
Member

Choose a reason for hiding this comment

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

@SirYwell Thanks for spotting this. You are right: Date.parse

Attempts to interpret the string s as a representation of a date and time.
If the attempt is successful...
If the attempt fails, an IllegalArgumentException is thrown.

@jaikiran I suggest to use the original code for catching exceptions: } catch (Exception e) { }

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right @SirYwell. It was a copy/paste error on my part. Thank you for catching it. I have updated the PR to fix that part and catch Exception like previously.

if (value != null) {
try {
return Date.parse(value);
} catch (NumberFormatException e) { }
Copy link
Member

Choose a reason for hiding this comment

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

@SirYwell Thanks for spotting this. You are right: Date.parse

Attempts to interpret the string s as a representation of a date and time.
If the attempt is successful...
If the attempt fails, an IllegalArgumentException is thrown.

@jaikiran I suggest to use the original code for catching exceptions: } catch (Exception e) { }

Copy link
Member

@simonis simonis left a comment

Choose a reason for hiding this comment

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

Looks good now. Thanks for finding the additional occurrence.

One final comment: could you please leave the empty catch blocks in one line, i.e.

} catch (NumberFormatException e) { }

instead of:

} catch (NumberFormatException e) {
}

This format is also recommended in the Java Style Guidelines for empty blocks.

@jaikiran
Copy link
Member Author

One final comment: could you please leave the empty catch blocks in one line

Done. Updated the PR with this suggested format.

Testing in progress to make sure there are no regressions from these changes.

Copy link
Member

@dfuch dfuch left a comment

Choose a reason for hiding this comment

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

Changes look good to me. Approving provided that tier2 passes.

@openjdk
Copy link

openjdk bot commented Nov 21, 2022

@jaikiran This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8297211: Expensive fillInStackTrace operation in HttpURLConnection.getOutputStream0 when no content-length in response

Reviewed-by: simonis, dfuchs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 16 new commits pushed to the master branch:

  • 57f5cfd: 8296399: crlNumExtVal might be null inside X509CRLSelector::match
  • 0b04a99: 8297347: Problem list compiler/debug/TestStress*.java
  • 0ac0148: 8297342: make LOG=debug is too verbose
  • d0a7938: 8286575: Document how properties in java.security are parsed
  • 5c33454: 8296472: Remove ObjectLocker around appendToClassPathForInstrumentation call
  • 0800813: 8293584: CodeCache::old_nmethods_do incorrectly filters is_unloading nmethods
  • 16ab754: 8196018: java/awt/Scrollbar/ScrollbarMouseWheelTest/ScrollbarMouseWheelTest.java fails
  • 8b8d848: 8293422: DWARF emitted by Clang cannot be parsed
  • 59d8f67: 8297265: G1: Remove unnecessary null-check in RebuildCodeRootClosure::do_code_blob
  • 2fc340a: 8148041: Test java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick fails on Ubuntu with mouseReleased event after double click on title bar
  • ... and 6 more: https://git.openjdk.org/jdk/compare/544e31722528d12fae0eb19271f85886680801a6...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 21, 2022
Copy link
Member

@simonis simonis left a comment

Choose a reason for hiding this comment

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

LGTM.

@jaikiran
Copy link
Member Author

The tests came back fine without any related failures.

Thank you everyone for the reviews and suggestions.

@jaikiran
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 22, 2022

Going to push as commit 392ac70.
Since your change was applied there have been 22 commits pushed to the master branch:

  • 5a45c25: 8297164: Update troff man pages and CheckManPageOptions.java
  • f12710e: 8288047: Accelerate Poly1305 on x86_64 using AVX512 instructions
  • cd6a203: 8297348: make CONF=xxx should match if xxx is an exact match
  • 817e039: 8297352: configure should check pandoc version
  • 15e2e28: 8297353: Regenerated checked-in html files with new pandoc
  • b366d17: 8294073: Performance improvement for message digest implementations
  • 57f5cfd: 8296399: crlNumExtVal might be null inside X509CRLSelector::match
  • 0b04a99: 8297347: Problem list compiler/debug/TestStress*.java
  • 0ac0148: 8297342: make LOG=debug is too verbose
  • d0a7938: 8286575: Document how properties in java.security are parsed
  • ... and 12 more: https://git.openjdk.org/jdk/compare/544e31722528d12fae0eb19271f85886680801a6...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 22, 2022
@openjdk openjdk bot closed this Nov 22, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 22, 2022
@openjdk
Copy link

openjdk bot commented Nov 22, 2022

@jaikiran Pushed as commit 392ac70.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

integrated Pull request has been integrated net net-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants