RFR: 8284673: Collapse identical catch branches in java.management
Bernd Eckenfels
ecki at zusammenkunft.net
Tue Apr 12 02:02:23 UTC 2022
Hello,
> new RuntimeException(exc1.getMessage())
I typically try to avoid swallowing the cause and especially the exception type of a inner exception, especially in this case where two different exceptions are caught. Better do tostring() and/or specify the exception as a cause to have chaining?
--
https://bernd.eckenfels.net
________________________________
From: serviceability-dev <serviceability-dev-retn at openjdk.java.net> on behalf of David Holmes <dholmes at openjdk.java.net>
Sent: Tuesday, April 12, 2022 3:52:38 AM
To: serviceability-dev at openjdk.java.net <serviceability-dev at openjdk.java.net>
Subject: Re: RFR: 8284673: Collapse identical catch branches in java.management
On Fri, 8 Apr 2022 12:19:03 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:
> Let's take advantage of Java 7 language feature - "Catching Multiple Exception Types".
> It simplifies code. Reduces duplication.
> Found by IntelliJ IDEA inspection Identical 'catch' branches in 'try' statement
Nice cleanup! Great to see the code duplication gone.
One minor additional edit requested below.
Thanks,
David
src/java.management/share/classes/javax/management/relation/RelationService.java line 1920:
> 1918: } catch (InstanceNotFoundException | ReflectionException exc1) {
> 1919: throw new RuntimeException(exc1.getMessage());
> 1920: } catch (MBeanException exc3) {
Please change exc3 to exc2
-------------
Marked as reviewed by dholmes (Reviewer).
PR: https://git.openjdk.java.net/jdk/pull/8161
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/serviceability-dev/attachments/20220412/024c37d3/attachment.htm>
More information about the serviceability-dev
mailing list