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

7113208: Incorrect javadoc on java.net.DatagramPacket.setLength() #10037

Closed
wants to merge 3 commits into from

Conversation

jaikiran
Copy link
Member

@jaikiran jaikiran commented Aug 26, 2022

Can I please get a review of this javadoc only change for DatagramPacket#setLength() method? This addresses https://bugs.openjdk.org/browse/JDK-7113208.

I haven't create a CSR because the javadoc was already stating the correct behaviour in the @throws documentation as follows:

@throws IllegalArgumentException if the length is negative,
* or if the length plus the offset is greater than the
* length of the packet's data buffer.

This commit merely fixes the main part of the javadoc.


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-7113208: Incorrect javadoc on java.net.DatagramPacket.setLength()

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10037

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 26, 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 Aug 26, 2022
@openjdk
Copy link

openjdk bot commented Aug 26, 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 Aug 26, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 26, 2022

Webrevs

Comment on lines +397 to +399
* will be used for receiving data. The {@code length} plus the
* {@link #getOffset() offset} must be lesser or equal to the
* length of the packet's data buffer.
Copy link
Member

Choose a reason for hiding this comment

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

The new text looks good to me. While you're at it I would suggest to rewrite the code that checks the length with something like:

        Preconditions.checkFromIndexSize(offset, length, buf.length,
                Preconditions.outOfBoundsExceptionFormatter(IllegalArgumentException::new));

Then figure out if we have a unit test that already checks this, and if not, write one!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hello Daniel, thank you for the review. I've updated the PR to implement the code change you suggested.

There's already test/jdk/java/net/DatagramPacket/Setters.java which has testSetLength to test this method. I've run the entire test/jdk/java/net/DatagramPacket tests with this change and they passed fine. I'll trigger a more comprehensive test run just to make sure nothing unexpected shows up.

Comment on lines +415 to +416
Preconditions.checkFromIndexSize(offset, length, buf.length,
Preconditions.outOfBoundsExceptionFormatter(IllegalArgumentException::new));
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for that. Maybe the bound checks in

     public synchronized void setData(byte[] buf, int offset, int length) {

could be replaced in a similar way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hello Daniel,

I've now updated this method too to use Preconditions. Additionally, a NullPointerException check which was implicit in this method (and noted by a code comment) has now been made an explicit check (using Objects.requireNonNull) in this updated version. I hope that's OK.

The existing Setters.java test case covers this method as well and I've run it after these changes to make sure it continues to pass.

* equal to the offset plus the length of the packet's buffer.
* will be used for receiving data. The {@code length} plus the
* {@link #getOffset() offset} must be lesser or equal to the
* length of the packet's data buffer.
Copy link
Contributor

Choose a reason for hiding this comment

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

The javadoc update looks okay.

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.

Thanks Jaikiran! LGTM!

@openjdk
Copy link

openjdk bot commented Sep 2, 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:

7113208: Incorrect javadoc on java.net.DatagramPacket.setLength()

Reviewed-by: 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 88 new commits pushed to the master branch:

  • 77e21c5: 8290529: C2: assert(BoolTest(btest).is_canonical()) failure
  • fcc0cf9: 8292375: Convert ProtectionDomainCacheTable to ResourceHashtable
  • 6fc58b8: 8293207: Add assert to JVM_ReferenceRefersTo to clarify its API
  • ce06a3b: 8293023: Change CardTable::is_in_young signature
  • 26cac08: 8293209: Parallel: Remove unused variables in PSParallelCompact::invoke
  • 46523b8: 8293219: Microsoft toolchain selection picks 32-bit tools over 64-bit
  • bc5ffc8: 8293100: RISC-V: Need to save and restore callee-saved FloatRegisters in StubGenerator::generate_call_stub
  • 98ce45f: 8292981: Unify and restructure integer printing format specifiers
  • 3ac91b0: 8293003: Review running time of Warn5 regression test
  • e0168a0: 8288012: AArch64: unnecessary macro expansion in stubGenerator_aarch64
  • ... and 78 more: https://git.openjdk.org/jdk/compare/3e187730162965981a5e6d238935e46d1015708e...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 Sep 2, 2022
@jaikiran
Copy link
Member Author

jaikiran commented Sep 3, 2022

Thank you Alan and Daniel for the reviews. tier1,tier2,tier3 testing went fine with these changes.

@jaikiran
Copy link
Member Author

jaikiran commented Sep 3, 2022

/integrate

@openjdk
Copy link

openjdk bot commented Sep 3, 2022

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

  • ac05bc8: 8293293: Move archive heap loading code out of heapShared.cpp
  • e1e6732: 8293319: [C2 cleanup] Remove unused other_path arg in Parse::adjust_map_after_if
  • 5757e21: 8292385: assert(ctrl == kit.control()) failed: Control flow was added although the intrinsic bailed out
  • 3993a1f: 8292067: Convert test/sun/management/jmxremote/bootstrap shell tests to java version
  • 83a3408: 8293315: Add back logging for Placeholders
  • b6477fd: 8293288: bootcycle build failure after JDK-8173605
  • 0c6094e: 8293188: x86_64: Introduce stubGenerator_x86_64.hpp
  • 2baeebb: 8293006: sun/tools/jhsdb/JStackStressTest.java fails with "UnalignedAddressException: 8baadbabe"
  • da99e3e: 8289400: Improve com/sun/jdi/TestScaffold error reporting
  • 77e21c5: 8290529: C2: assert(BoolTest(btest).is_canonical()) failure
  • ... and 87 more: https://git.openjdk.org/jdk/compare/3e187730162965981a5e6d238935e46d1015708e...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 3, 2022

@jaikiran Pushed as commit a366e82.

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

@jaikiran jaikiran deleted the 7113208 branch September 3, 2022 05:54
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
3 participants