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

Fix the -jvm-debug and -h flags in the ash template #1630

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

qwe2
Copy link

@qwe2 qwe2 commented Aug 22, 2024

This should fix issues like #1523

@lightbend-cla-validator

@lightbend-cla-validator

@lightbend-cla-validator

Hi @qwe2,

Thank you for your contribution! We really value the time you've taken to put this together.

Before we proceed with reviewing this pull request, please sign the Lightbend Contributors License Agreement:

http://www.lightbend.com/contribute/cla

@qwe2
Copy link
Author

qwe2 commented Aug 22, 2024

Interestingly the addDebugger syntax from bash-template is only compatible with Java 9+, but the GH workflow is still pulling JDK 1.8. java_version_check also checks for Java 8, not 9. Not sure if this is intentional...

@muuki88
Copy link
Contributor

muuki88 commented Aug 22, 2024

Thanks for tackling this 💪

I'll be on vacation . Maybe @dwickern can take a look 😊

@qwe2
Copy link
Author

qwe2 commented Nov 28, 2024

I've been a bit busy and wasn't sure what to do about Java 8 compat, but I ended up adding some checks so that -jvm-debug works on both ash and bash for Java 8 as well.

@muuki88
Copy link
Contributor

muuki88 commented Jan 5, 2025

Hi @qwe2

Sorry for the waiting - I'll try to find some time to take a deeper look!

@dwickern
Copy link
Collaborator

dwickern commented Jan 5, 2025

Re: Java 8 compatibility, I found the relevant change in the JDK 9 release notes (bold mine)

JDWP socket connector accept only local connections by default

The JDWP socket connector has been changed to bind to localhost only if no ip address or hostname is specified on the agent command line. A hostname of asterisk (*) may be used to achieve the old behavior which is to bind the JDWP socket connector to all available interfaces; this is not secure and not recommended.
JDK-8041435

IMO we should keep the secure defaults and let users decide what address to bind to:
-jvm-debug 5005 - listen on all addresses (Java 8) or only localhost (Java 9+)
-jvm-debug localhost:5005 - works the same on all Java versions
-jvm-debug '*:5005' - listen on all addresses for Java 9+ (quotes needed in some shells to prevent * expansion)

That means we can remove all the Java version detection. We should also revert #1546 to keep bash and ash consistent.

@qwe2
Copy link
Author

qwe2 commented Jan 6, 2025

Sounds good, but this would be a breaking change then:

-jvm-debug 5005 - listen on all addresses (Java 8) or only localhost (Java 9+)

This currently means *:5005 on JDK 9+, but going forward, it would mean localhost:5005 instead. Is that acceptable?

@muuki88
Copy link
Contributor

muuki88 commented Jan 6, 2025

I'm with @dwickern on the secure setting by default and also reflecting what the JVM does. If you are not using sbt-native-packager and you use -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 it will also break when you upgrade the JVM.

After all, upgrading a major version of the JVM must be tested and I think it's better if sbt-native-packager doesn't try to magically add a migration path.

@qwe2
Copy link
Author

qwe2 commented Jan 22, 2025

I've reverted #1546 and removed the major version checks. Note that this would be a breaking change for anyone currently using -jvm-debug 5005 on JDK 9+. They would have to change it to -jvm-debug '*:5005' to match the current behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants