summary |
shortlog |
log |
commit | commitdiff |
review |
tree
raw |
patch |
inline | side by side (from parent 1:
78e0b70)
The checks here are based on old assumption that the listener
would be set to null, which does not hold true for quite some
time. Update the check to close a simple race.
JIRA: MDSAL-545
Change-Id: I950ffcbcf732d4c24dcad675b81c2889465d9045
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit
91749a5a5fb089e74306f288d786acb8d3c450ae)
private final ScheduledThreadPoolExecutor observer;
private final ExecutorService executor;
private final ScheduledThreadPoolExecutor observer;
private final ExecutorService executor;
- private volatile Multimap<SchemaPath, ListenerRegistration<? extends DOMNotificationListener>> listeners =
+ private volatile Multimap<SchemaPath, AbstractListenerRegistration<? extends DOMNotificationListener>> listeners =
ImmutableMultimap.of();
@VisibleForTesting
ImmutableMultimap.of();
@VisibleForTesting
@Override
public synchronized <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(
final T listener, final Collection<SchemaPath> types) {
@Override
public synchronized <T extends DOMNotificationListener> ListenerRegistration<T> registerNotificationListener(
final T listener, final Collection<SchemaPath> types) {
- final ListenerRegistration<T> reg = new AbstractListenerRegistration<T>(listener) {
+ final AbstractListenerRegistration<T> reg = new AbstractListenerRegistration<T>(listener) {
@Override
protected void removeRegistration() {
synchronized (DOMNotificationRouter.this) {
@Override
protected void removeRegistration() {
synchronized (DOMNotificationRouter.this) {
};
if (!types.isEmpty()) {
};
if (!types.isEmpty()) {
- final Builder<SchemaPath, ListenerRegistration<? extends DOMNotificationListener>> b =
+ final Builder<SchemaPath, AbstractListenerRegistration<? extends DOMNotificationListener>> b =
ImmutableMultimap.builder();
b.putAll(listeners);
ImmutableMultimap.builder();
b.putAll(listeners);
* @param newListeners is used to notify listenerTypes changed
*/
private void replaceListeners(
* @param newListeners is used to notify listenerTypes changed
*/
private void replaceListeners(
- final Multimap<SchemaPath, ListenerRegistration<? extends DOMNotificationListener>> newListeners) {
+ final Multimap<SchemaPath, AbstractListenerRegistration<? extends DOMNotificationListener>> newListeners) {
listeners = newListeners;
notifyListenerTypesChanged(newListeners.keySet());
}
listeners = newListeners;
notifyListenerTypesChanged(newListeners.keySet());
}
}
private ListenableFuture<Void> publish(final long seq, final DOMNotification notification,
}
private ListenableFuture<Void> publish(final long seq, final DOMNotification notification,
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers) {
final DOMNotificationRouterEvent event = disruptor.get(seq);
final ListenableFuture<Void> future = event.initialize(notification, subscribers);
disruptor.getRingBuffer().publish(seq);
final DOMNotificationRouterEvent event = disruptor.get(seq);
final ListenableFuture<Void> future = event.initialize(notification, subscribers);
disruptor.getRingBuffer().publish(seq);
@Override
public ListenableFuture<? extends Object> putNotification(final DOMNotification notification)
throws InterruptedException {
@Override
public ListenableFuture<? extends Object> putNotification(final DOMNotification notification)
throws InterruptedException {
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers =
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers =
listeners.get(notification.getType());
if (subscribers.isEmpty()) {
return NO_LISTENERS;
listeners.get(notification.getType());
if (subscribers.isEmpty()) {
return NO_LISTENERS;
@SuppressWarnings("checkstyle:IllegalCatch")
@VisibleForTesting
ListenableFuture<? extends Object> tryPublish(final DOMNotification notification,
@SuppressWarnings("checkstyle:IllegalCatch")
@VisibleForTesting
ListenableFuture<? extends Object> tryPublish(final DOMNotification notification,
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers) {
final long seq;
try {
seq = disruptor.getRingBuffer().tryNext();
final long seq;
try {
seq = disruptor.getRingBuffer().tryNext();
@Override
public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification) {
@Override
public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification) {
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers =
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers =
listeners.get(notification.getType());
if (subscribers.isEmpty()) {
return NO_LISTENERS;
listeners.get(notification.getType());
if (subscribers.isEmpty()) {
return NO_LISTENERS;
@Override
public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification, final long timeout,
final TimeUnit unit) throws InterruptedException {
@Override
public ListenableFuture<? extends Object> offerNotification(final DOMNotification notification, final long timeout,
final TimeUnit unit) throws InterruptedException {
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers =
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers =
listeners.get(notification.getType());
if (subscribers.isEmpty()) {
return NO_LISTENERS;
listeners.get(notification.getType());
if (subscribers.isEmpty()) {
return NO_LISTENERS;
import java.util.Collection;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import java.util.Collection;
import org.opendaylight.mdsal.dom.api.DOMNotification;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
/**
* A single notification event in the disruptor ringbuffer. These objects are reused,
/**
* A single notification event in the disruptor ringbuffer. These objects are reused,
final class DOMNotificationRouterEvent {
static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
final class DOMNotificationRouterEvent {
static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
- private Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers;
+ private Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers;
private DOMNotification notification;
private SettableFuture<Void> future;
private DOMNotification notification;
private SettableFuture<Void> future;
@SuppressWarnings("checkstyle:hiddenField")
ListenableFuture<Void> initialize(final DOMNotification notification,
@SuppressWarnings("checkstyle:hiddenField")
ListenableFuture<Void> initialize(final DOMNotification notification,
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers) {
this.notification = requireNonNull(notification);
this.subscribers = requireNonNull(subscribers);
this.future = SettableFuture.create();
this.notification = requireNonNull(notification);
this.subscribers = requireNonNull(subscribers);
this.future = SettableFuture.create();
}
void deliverNotification() {
}
void deliverNotification() {
- for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
- final DOMNotificationListener l = r.getInstance();
- if (l != null) {
- l.onNotification(notification);
+ for (AbstractListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
+ if (r.notClosed()) {
+ r.getInstance().onNotification(notification);
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener;
import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
import org.opendaylight.mdsal.dom.api.DOMNotificationPublishService;
import org.opendaylight.mdsal.dom.spi.DOMNotificationSubscriptionListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
import org.opendaylight.yangtools.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
@Override
protected ListenableFuture<? extends Object> tryPublish(final DOMNotification notification,
@Override
protected ListenableFuture<? extends Object> tryPublish(final DOMNotification notification,
- final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
+ final Collection<AbstractListenerRegistration<? extends DOMNotificationListener>> subscribers) {
return DOMNotificationPublishService.REJECTED;
}
return DOMNotificationPublishService.REJECTED;
}