DOMMountPointServiceImpl should not fail and propagate uncaught
exceptions from mount point listeners. When invocation of a registered
listener onMounPpointCreated or onMounPointRemoved callback fails, just
log the error and continue execution.
Change-Id: I5d182b610c0b5749cfe01efc13bc1dddfffa5283
Signed-off-by: Jakub Morvay <jakub.morvay@gmail.com>
return listeners.register(listener);
}
return listeners.register(listener);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
final YangInstanceIdentifier mountPointId = mountPoint.getIdentifier();
synchronized (mountPoints) {
final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
}
private ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
final YangInstanceIdentifier mountPointId = mountPoint.getIdentifier();
synchronized (mountPoints) {
final DOMMountPoint prev = mountPoints.putIfAbsent(mountPointId, mountPoint);
checkState(prev == null, "Mount point %s already exists as %s", mountPointId, prev);
}
- listeners.forEach(listener -> listener.getInstance().onMountPointCreated(mountPointId));
+ listeners.forEach(listener -> {
+ try {
+ listener.getInstance().onMountPointCreated(mountPointId);
+ } catch (final Exception ex) {
+ LOG.error("Listener {} failed on mount point {} created event", listener, mountPoint, ex);
+ }
+ });
return new AbstractObjectRegistration<DOMMountPoint>(mountPoint) {
@Override
return new AbstractObjectRegistration<DOMMountPoint>(mountPoint) {
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void unregisterMountPoint(final YangInstanceIdentifier mountPointId) {
synchronized (mountPoints) {
if (mountPoints.remove(mountPointId) == null) {
private void unregisterMountPoint(final YangInstanceIdentifier mountPointId) {
synchronized (mountPoints) {
if (mountPoints.remove(mountPointId) == null) {
- listeners.forEach(listener -> listener.getInstance().onMountPointRemoved(mountPointId));
+ listeners.forEach(listener -> {
+ try {
+ listener.getInstance().onMountPointRemoved(mountPointId);
+ } catch (final Exception ex) {
+ LOG.error("Listener {} failed on mount point {} removed event", listener, mountPointId, ex);
+ }
+ });
}
final class DOMMountPointBuilderImpl implements DOMMountPointBuilder {
}
final class DOMMountPointBuilderImpl implements DOMMountPointBuilder {