Skip to content

Commit

Permalink
Exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjwalls committed Nov 26, 2024
1 parent 1dd190f commit 9628234
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,10 @@ private static void addMBean(MBeanServer mbs, Object mbean, String mbeanName) {

try {
mbs.registerMBean(mbean, objName);
} catch (InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) {
// ignore the exception, e.g. an instance with the object name exists
} catch (InstanceAlreadyExistsException iaee) {
// if an instance with the object name exists in the MBeanServer, ignore the exception
} catch (Exception e) {
throw new RuntimeException(e);
}
}

Expand Down Expand Up @@ -501,8 +503,10 @@ private static void unregisterMBean(MBeanServer mbs, String mbeanName) {

try {
mbs.unregisterMBean(objName);
} catch (InstanceNotFoundException | MBeanRegistrationException | RuntimeOperationsException e) {
// ignore exception
} catch (InstanceNotFoundException infe) {
// ignore exception if not found
} catch (Exception e) {
throw new RuntimeException(e);
}
}

Expand Down

0 comments on commit 9628234

Please sign in to comment.