-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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][functions] Fix netty.DnsResolverUtil compat issue on JDK9+ for the function Runtimes #16423
Conversation
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
Outdated
Show resolved
Hide resolved
@@ -320,6 +320,11 @@ public static List<String> getCmd(InstanceConfig instanceConfig, | |||
|
|||
args.add("-Dio.netty.tryReflectionSetAccessible=true"); | |||
|
|||
// Needed for netty.DnsResolverUtil on JDK9+ | |||
if (!System.getProperty("java.version").startsWith("1.")) { | |||
args.add("--add-opens java.base/sun.net=ALL-UNNAMED"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want to add other modules too? at least look at the changes that resulted in these and see if they are applicable to the functions
$ ggrep -rI "\-\-add-opens"
buildtools/pom.xml: --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
buildtools/pom.xml: --add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
buildtools/dependency-reduced-pom.xml: <test.additional.args>--add-opens java.base/jdk.internal.loader=ALL-UNNAMED
buildtools/dependency-reduced-pom.xml: --add-opens java.base/java.lang=ALL-UNNAMED</test.additional.args>
bin/bookkeeper:# Start --add-opens options
bin/bookkeeper:# '--add-opens' option is not supported in jdk8
bin/bookkeeper: OPTS="$OPTS --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util.zip=ALL-UNNAMED"
bin/bookkeeper: OPTS="$OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED"
bin/function-localrunner:# Start --add-opens options
bin/function-localrunner:# '--add-opens' option is not supported in jdk8
bin/function-localrunner: OPTS="$OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED"
bin/pulsar:# Start --add-opens options
bin/pulsar:# '--add-opens' option is not supported in jdk8
bin/pulsar: OPTS="$OPTS --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util.zip=ALL-UNNAMED"
bin/pulsar: OPTS="$OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED"
bin/pulsar: OPTS="$OPTS --add-opens java.base/sun.net=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED"
bin/pulsar-client:# Start --add-opens options
bin/pulsar-client:# '--add-opens' option is not supported in jdk8
bin/pulsar-client: OPTS="$OPTS --add-opens java.base/sun.net=ALL-UNNAMED"
pom.xml: --add-opens java.base/jdk.internal.loader=ALL-UNNAMED
pom.xml: --add-opens java.base/java.lang=ALL-UNNAMED <!--Mockito-->
pom.xml: --add-opens java.base/java.io=ALL-UNNAMED <!--Bookkeeper NativeIO -->
pom.xml: --add-opens java.base/sun.net=ALL-UNNAMED <!--netty.DnsResolverUtil-->
pom.xml: --add-opens java.management/sun.management=ALL-UNNAMED <!--JvmDefaultGCMetricsLogger-->
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
java.base/sun.net
should be enough for Pulsar client since it's the same configuration used in pulsar-client CLI tool.
@@ -320,6 +320,11 @@ public static List<String> getCmd(InstanceConfig instanceConfig, | |||
|
|||
args.add("-Dio.netty.tryReflectionSetAccessible=true"); | |||
|
|||
// Needed for netty.DnsResolverUtil on JDK9+ | |||
if (!System.getProperty("java.version").startsWith("1.")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about using commons-lang3 utility
SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should have a consistent approach across the code base, do you see other cases in Java code where we detect the Java version ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. That's the only place I found
095032d
to
23ab6be
Compare
pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java
Outdated
Show resolved
Hide resolved
3e43cf8
to
0c306ca
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/pulsarbot rerun-failure-checks |
2 similar comments
/pulsarbot rerun-failure-checks |
/pulsarbot rerun-failure-checks |
/pulsarbot rerun-failure-checks |
e1691be
to
9cace6d
Compare
…the function Runtimes
/pulsarbot rerun-failure-checks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…the function Runtimes (apache#16423)
…the function Runtimes (apache#16423)
Motivation
DnsResolverUtil fails to get existing DNS TTL settings. This happens in Java 17.
This has been fixed for the pulsar-client and pulsar launcher scripts in #15349 and #15540
This PR is to do the same for the Runtime java command.
Modifications
Detect the java version of the function worker and add the JVM flag
--add-opens java.base/sun.net=ALL-UNNAMED
if the version is 9+Documentation
Check the box below or label this PR directly.
Need to update docs?
doc-required
(Your PR needs to update docs and you will update later)
doc-not-needed
fix
doc
(Your PR contains doc changes)
doc-complete
(Docs have been already added)