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

DnsResolverUtil "Cannot get DNS TTL settings from sun.net.InetAddressCachePolicy class" in Java 17 #15349

Closed
lhotari opened this issue Apr 27, 2022 · 2 comments · Fixed by #15964
Labels
type/bug The PR fixed a bug or issue reported a bug

Comments

@lhotari
Copy link
Member

lhotari commented Apr 27, 2022

Describe the bug

DnsResolverUtil fails to get existing DNS TTL settings. This happens in Java 17. Error message:

WARN  org.apache.pulsar.common.util.netty.DnsResolverUtil - Cannot get DNS TTL settings from sun.net.InetAddressCachePolicy class
  java.lang.IllegalAccessException: class org.apache.pulsar.common.util.netty.DnsResolverUtil cannot access class sun.net.InetAddressCachePolicy (in module java.base) because module java.base does not export sun.net to unnamed module @3932c79a
  	at jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:392) ~[?:?]
  	at java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:674) ~[?:?]
  	at java.lang.reflect.Method.invoke(Method.java:560) ~[?:?]
  	at org.apache.pulsar.common.util.netty.DnsResolverUtil.<clinit>(DnsResolverUtil.java:46) ~[org.apache.pulsar-pulsar-common-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]
  	at org.apache.pulsar.client.impl.ConnectionPool.createDnsNameResolver(ConnectionPool.java:116) ~[org.apache.pulsar-pulsar-client-original-2.11.0-SNAPSHOT.jar:2.11.0-SNAPSHOT]

To Reproduce

Use Pulsar Java Client in Java 17

Expected behavior

Pulsar Java Client should be able to detect DNS TTL settings used in Java and apply them to Netty's DnsNameResolverBuilder.

Additional context
#15219

@Technoboy-
Copy link
Contributor

I only know to add vm options --add-opens=java.management/sun.management=ALL-UNNAMED --add-opens=java.base/sun.net=ALL-UNNAMED could solve the issue

@lgxbslgx
Copy link
Contributor

@lhotari @Technoboy- Have you started the work locally? If not, I would like to take it over.

michaeljmarshall pushed a commit that referenced this issue Jun 9, 2022
Fixes #15349


### Motivation

When using the JDK17, pulsar-client throws exception `module java.base does not export sun.net to unnamed module`, it is good to fix it.

### Modifications

Add `--add-opens java.base/sun.net=ALL-UNNAMED` to java option when using JDK17.

### Verifying this change

- [x] Make sure that the change passes the CI checks.

### Documentation

Check the box below or label this PR directly.

Need to update docs? 

- [x] `doc-not-needed`
nicoloboschi pushed a commit to datastax/pulsar that referenced this issue Jun 28, 2022
Fixes apache#15349

### Motivation

When using the JDK17, pulsar-client throws exception `module java.base does not export sun.net to unnamed module`, it is good to fix it.

### Modifications

Add `--add-opens java.base/sun.net=ALL-UNNAMED` to java option when using JDK17.

### Verifying this change

- [x] Make sure that the change passes the CI checks.

### Documentation

Check the box below or label this PR directly.

Need to update docs?

- [x] `doc-not-needed`

(cherry picked from commit 9d16b91)
nicoloboschi pushed a commit to datastax/pulsar that referenced this issue Jun 28, 2022
Fixes apache#15349

### Motivation

When using the JDK17, pulsar-client throws exception `module java.base does not export sun.net to unnamed module`, it is good to fix it.

### Modifications

Add `--add-opens java.base/sun.net=ALL-UNNAMED` to java option when using JDK17.

### Verifying this change

- [x] Make sure that the change passes the CI checks.

### Documentation

Check the box below or label this PR directly.

Need to update docs?

- [x] `doc-not-needed`

(cherry picked from commit 9d16b91)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants