}
} else if (streamName.contains(RestconfImpl.NOTIFICATION_STREAM)) {
final List<NotificationListenerAdapter> listeners = Notificator.getNotificationListenerFor(streamName);
- if (!listeners.isEmpty() && (listeners != null)) {
+ if (listeners != null && !listeners.isEmpty()) {
for (final NotificationListenerAdapter listener : listeners) {
listener.addSubscriber(ctx.channel());
LOG.debug("Subscriber successfully registered.");
// Send the response and close the connection if necessary.
final ChannelFuture f = ctx.channel().writeAndFlush(res);
- if (!isKeepAlive(req) || (res.getStatus().code() != 200)) {
+ if (!isKeepAlive(req) || res.getStatus().code() != 200) {
f.addListener(ChannelFutureListener.CLOSE);
}
}
if (listener != null) {
listener.removeSubscriber(ctx.channel());
LOG.debug("Subscriber successfully registered.");
+
+ Notificator.removeListenerIfNoSubscriberExists(listener);
}
- Notificator.removeListenerIfNoSubscriberExists(listener);
} else if (streamName.contains(RestconfImpl.NOTIFICATION_STREAM)) {
final List<NotificationListenerAdapter> listeners = Notificator.getNotificationListenerFor(streamName);
- if (!listeners.isEmpty() && (listeners != null)) {
+ if (listeners != null && !listeners.isEmpty()) {
for (final NotificationListenerAdapter listener : listeners) {
listener.removeSubscriber(ctx.channel());
}
}
return;
} else if (frame instanceof PingWebSocketFrame) {
- ctx.channel().write(new PongWebSocketFrame(frame.content().retain()));
+ ctx.channel().writeAndFlush(new PongWebSocketFrame(frame.content().retain()));
return;
}
}
@Override
public void exceptionCaught(final ChannelHandlerContext ctx, final Throwable cause) throws Exception {
- if (!(cause instanceof java.nio.channels.ClosedChannelException)) {
- // LOG.info("Not expected error cause: ", cause.toString());
- }
ctx.close();
}