Skip to content

Commit

Permalink
8299470: sun/jvm/hotspot/SALauncher.java handling of negative rmiport…
Browse files Browse the repository at this point in the history
… args

Reviewed-by: clanger, sspitsyn, kevinw
  • Loading branch information
MBaesken committed Jan 5, 2023
1 parent 578c287 commit 2ccdefc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -59,7 +59,8 @@ private void extractOptarg(String opt) {
}

if (! _argv[_optind].isEmpty() && _argv[_optind].charAt(0) == '-') {
throw new SAGetoptException("Argument is expected for '" + opt + "'");
throw new SAGetoptException("Successor argument without leading - is expected for '" + opt +
"' but we got '" + _argv[_optind] + "'");
}

_optarg = _argv[_optind];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -500,7 +500,8 @@ public static void main(String[] args) {
func.accept(oldArgs);
}
} catch (SAGetoptException e) {
System.err.println(e.getMessage());
System.err.println("SA agent option related exception occurred: " + e.getMessage());
e.printStackTrace();
toolHelp(args[0]);
// Exit with error status
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -101,12 +101,18 @@ private static void testWithPid(final boolean useRmiPort, final boolean useRegis
int registryPort = REGISTRY_DEFAULT_PORT;
if (useRegistryPort) {
registryPort = Utils.findUnreservedFreePort(REGISTRY_DEFAULT_PORT);
if (registryPort == -1) {
throw new RuntimeException("Cannot find a registryPort, findUnreservedFreePort returns -1");
}
jhsdbLauncher.addToolArg("--registryport");
jhsdbLauncher.addToolArg(Integer.toString(registryPort));
}

final int rmiPort = useRmiPort ? Utils.findUnreservedFreePort(REGISTRY_DEFAULT_PORT, registryPort) : -1;
if (useRmiPort) {
if (rmiPort == -1) {
throw new RuntimeException("Cannot find an rmiPort, findUnreservedFreePort returns -1");
}
jhsdbLauncher.addToolArg("--rmiport");
jhsdbLauncher.addToolArg(Integer.toString(rmiPort));
}
Expand Down

5 comments on commit 2ccdefc

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2ccdefc Jan 12, 2023

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 2ccdefc8 to openjdk/jdk17u-dev due to conflicts in the following files:

  • test/hotspot/jtreg/serviceability/sa/sadebugd/SADebugDTest.java

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk17u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk17u-dev master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b MBaesken-backport-2ccdefc8

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk 2ccdefc81c0ea2ea5c4380bb045aa82ad1eb8205

# Backport the commit
$ git cherry-pick --no-commit 2ccdefc81c0ea2ea5c4380bb045aa82ad1eb8205
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 2ccdefc81c0ea2ea5c4380bb045aa82ad1eb8205'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk17u-dev with the title Backport 2ccdefc81c0ea2ea5c4380bb045aa82ad1eb8205.

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 2ccdefc Jan 16, 2023

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch MBaesken-backport-2ccdefc8 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 2ccdefc8 from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 5 Jan 2023 and was reviewed by Christoph Langer, Serguei Spitsyn and Kevin Walls.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-2ccdefc8:MBaesken-backport-2ccdefc8
$ git checkout MBaesken-backport-2ccdefc8
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev MBaesken-backport-2ccdefc8

Please sign in to comment.