jmx-dev RFR: 8345079: Simplify/cleanup Exception handling in RMIConnectionImpl

Kevin Walls kevinw at openjdk.org
Fri Jan 17 18:21:36 UTC 2025


On Fri, 17 Jan 2025 14:19:31 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> This is a post-SecurityManager-removal cleanup, following-on from:
>> 
>> 8344394: Remove SecurityManager and related calls from java.management.rmi 
>> 
>> 
>> Remove mention of "privilege" in Exception handling in RMIConnectionImpl.
>> Remove wrapping of Exceptions in PrivilegedActionException.
>> 
>> The methods that invoke an operation handle expected Exceptions, but also need to handle SecurityException and RuntimeException, to avoid their default case of wrapping an Exception in an IOException to signal a problem.
>
> src/java.management.rmi/share/classes/javax/management/remote/rmi/RMIConnectionImpl.java line 212:
> 
>> 210:                 throw (SecurityException) e;
>> 211:             if (e instanceof RuntimeException)
>> 212:                 throw (RuntimeException) e;
> 
> Throughout all these changes: SecurityException is  a RuntimeException, so you do not need to check for both.
> 
> An alternative is to:
> 
> } catch (RuntimeException r) {
>     throw r;
> } catch (Exception e) {
>     ....
> }

OK sure, I was just making it super explicit.  Can update.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/23072#discussion_r1920580855


More information about the jmx-dev mailing list