[apache5-client] Fail fast when SecurityManager lacks TCP_KEEPIDLE/TCP_KEEPINTERVAL/TCP_KEEPCOUNT permissions.#6992
Conversation
…ctive and jdk.net.NetworkPermission setOption.TCP_KEEPIDLE, setOption.TCP_KEEPINTERVAL, setOption.TCP_KEEPCOUNT are not granted
| } | ||
|
|
||
| try { | ||
| Class<?> permClass = ClassLoaderHelper.loadClass("jdk.net.NetworkPermission", Apache5HttpClient.class); |
There was a problem hiding this comment.
Note that NetworkPermission is marked for forRemoval in Java 25 thus loading it from ClassLoaderHelper to prevent ClassNotFoundException for future Java versions.
https://docs.oracle.com/en/java/javase/26/docs/api/jdk.net/jdk/net/NetworkPermission.html
…eption other than one expected
b696460 to
697b152
Compare
|
Not a blocker, but can we add a test that uses a security manager with expected permissions enabled + makes an API call so we can catch any instances where more permissions have to be granted, for example in a new Apache 5.x minor version. |
Good call out. |
| try { | ||
| Class<?> permClass = ClassLoaderHelper.loadClass("jdk.net.NetworkPermission", Apache5HttpClient.class); | ||
| for (String permName : REQUIRED_TCP_SOCKET_OPTION_PERMISSIONS) { | ||
| java.security.Permission perm = |
There was a problem hiding this comment.
nit: do we need the fully qualified import right here in the body of class? Can we use a top level import instead?
|
This pull request has been closed and the conversation has been locked. Comments on closed PRs are hard for our team to see. If you need more assistance, please open a new issue that references this one. |
Motivation and Context
Modifications
jkdk.net.NetworkPermissionentries when a SecurityManager is active.IllegalStateExceptionlisting the missing permissions at client construction time instead of AccessControlException at first request.Testing
Screenshots (if appropriate)
Types of changes
License