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

8319651: Several network tests ignore vm flags when start java process #17787

Closed
wants to merge 6 commits into from

Conversation

DarraghClarke
Copy link
Contributor

@DarraghClarke DarraghClarke commented Feb 9, 2024

Currently these tests ignore vm flags, In most cases I've updated them to use ProcessTools.createTestJavaProcessBuilder this usually required some cleanup also.

test/jdk/java/net/ServerSocket/AcceptCauseFileDescriptorLeak.java and test/jdk/java/net/URLConnection/6212146/TestDriver.java have been set to use @require vm.flagless because they both use sh commands.

I've ran these changes against tiers 1-3 and everything seems stable


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-8319651: Several network tests ignore vm flags when start java process (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17787

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 9, 2024

👋 Welcome back dclarke! 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 Feb 9, 2024
@openjdk
Copy link

openjdk bot commented Feb 9, 2024

@DarraghClarke The following labels will be automatically applied to this pull request:

  • net
  • security

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

@openjdk openjdk bot added security security-dev@openjdk.org net net-dev@openjdk.org labels Feb 9, 2024
@mlbridge
Copy link

mlbridge bot commented Feb 9, 2024

Webrevs

new ProcessBuilder(
java, "-cp", ".",
ProcessTools.createTestJavaProcessBuilder(
"-cp", ".",
Copy link
Member

Choose a reason for hiding this comment

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

If I'm not mistaken, this will result in the -cp option being passed twice, with different values, to the java sub process. I believe that ProcessTools.createTestJavaProcessBuilder will end up passing "-cp <java.class.path>" to the subprocess, unless -Dtest.noclasspath=false is defined in the parent process.
Tough I could not find what would happen if -cp is passed twice in man java - it appears that the long standing behaviour is that the last one wins - so I guess that's OK, as I doubt this behaviour (last one wins) could be changed...

An alternative could be to create a new method in ProcessTools that would allow to pass a flag to prevent the addition of -cp <java.class.path> when that's not desiravle, and call that here - and in all other places where -cp is passed to ProcessTools.createTestJavaProcessBuilder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be possible to change the createJavaProcessBuilder method in ProcessTools to include something to check if -cp is already an argument being passed?

maybe something like this?

if (!noCP && !args.contains("-cp")) {
            args.add("-cp");
            args.add(System.getProperty("java.class.path"));
        }

Copy link
Member

Choose a reason for hiding this comment

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

That's not a bad idea. What I would recommend in that case would be to not do anything here - but rather log another issue against ProcessTools.createTestJavaProcessBuilder.
Then proceed with this PR without changing anything...

Copy link
Member

Choose a reason for hiding this comment

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

Hello Darragh, Daniel,

As for introducing a new method on ProcessTools class, I don't know if it's needed - I feel that the ProcessTools class is already getting too complex because of the various similarly named methods. I think it might be better to reuse some of those existing /test/lib utility methods to achieve the same, something like:

final List<String> command = new ArrayList<>();
command.add(JDKToolFinder.getJDKTool("java"));
command.addAll(jdk.test.lib.Utils.prependTestJavaOpts("-cp", classpath, className, appArgs));
final ProcessBuilder pb = new ProcessBuilder(command);
final OutputAnalyzer outputAnalyzer = ProcessTools.executeCommand(pb);

I haven't tried out this snippet to be sure this works as expected.

I am not suggesting we do this change in this current PR.

Copy link
Member

Choose a reason for hiding this comment

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

Hi Jaikiran,

What Darragh suggested was to modify the current method in ProcessTools to not add -cp <java.class.path> if the argument it is given already contains -cp. Since the first -cp added by the ProcessTools should be ignored anyway by the compiler (last one wins) - then I think it's a good idea, but to follow up outside of the PR.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry Daniel and Darragh, I misunderstood the discussion and thought it was a proposal to add a new method in that class. What you suggest about changing the implementation of that existing method, in a separate PR, sounds fine to me.

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.

Given the latest suggestions I'm good with this.

@openjdk
Copy link

openjdk bot commented Feb 14, 2024

@DarraghClarke 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:

8319651: Several network tests ignore vm flags when start java process

Reviewed-by: dfuchs, jpai

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

  • 0aaec97: 8325763: Revert properties: vm.opt.x.*
  • 4018b2b: 8323782: Race: Thread::interrupt vs. AbstractInterruptibleChannel.begin
  • 2705ed0: 8325074: ZGC fails assert(index == 0 || is_power_of_2(index)) failed: Incorrect load shift: 11
  • 3d85103: 8316813: NMT: Using WhiteBox API, virtual memory tracking should also be stressed in JMH tests
  • ba8db1f: 8325876: crashes in docker container tests on Linuxppc64le Power8 machines
  • 18cea82: 8319801: Recursive lightweight locking: aarch64 implementation
  • 9029bf6: 8316451: 6 java/lang/instrument/PremainClass tests ignore VM flags
  • 99c9ae1: 8323664: java/awt/font/JNICheck/FreeTypeScalerJNICheck.java still fails with JNI warning on some Windows configurations
  • 0fdfdf7: 8325983: Build failure after JDK-8324580
  • 3b1062d: 8322239: [macos] a11y : java.lang.NullPointerException is thrown when focus is moved on the JTabbedPane
  • ... and 113 more: https://git.openjdk.org/jdk/compare/4abb10eb0b8ec5aab2e276f5c3a99ff5db7bc877...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 Feb 14, 2024
Copy link
Member

@jaikiran jaikiran left a comment

Choose a reason for hiding this comment

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

These changes look good to me.

The TLSWontNegotiateDisabledCipherAlgos.java would need a copyright year update.

@DarraghClarke
Copy link
Contributor Author

Thanks for the suggestions and feedback, I think I've addressed everything now so will leave some time in case there is anything else and to rerun tests but will merge later.

@DarraghClarke
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Feb 20, 2024

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

  • 4957d6a: 8325441: IGV: update pom.xml such that IntelliJ can import as maven project
  • d60331a: 8326196: Serial: Remove SerialHeap::generation_iterate
  • beed414: 8326209: G1: Remove G1ConcurrentMark::_total_cleanup_time
  • 56073cd: 8326171: Serial: Remove VerifyGCLevel
  • bb675af: 8325542: CTW: Runner can produce negative StressSeed
  • 5bf859c: 8325610: CTW: Add StressIncrementalInlining to stress options
  • 0d28531: 8318812: LauncherHelper.checkAndLoadMain closes jar file that's about to be re-opened
  • 69a11c7: 8326222: Fix copyright year in src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
  • 9fbcc00: 8326127: JFR: Add SafepointCleanupTask to hardToTestEvents of TestLookForUntestedEvents
  • 7d32a1a: 8326111: JFR: Cleanup for JFR_ONLY
  • ... and 156 more: https://git.openjdk.org/jdk/compare/4abb10eb0b8ec5aab2e276f5c3a99ff5db7bc877...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 20, 2024

@DarraghClarke Pushed as commit 9538f5d.

💡 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 security security-dev@openjdk.org
Development

Successfully merging this pull request may close these issues.

4 participants