Router: Don't unregister a message without a selector (ticket #2771)

This commit is contained in:
zzz
2020-09-28 13:59:30 +00:00
parent cd699c587b
commit 2d9933a4a9
2 changed files with 9 additions and 5 deletions

View File

@@ -33,16 +33,18 @@ public class OutNetMessagePool {
*
*/
public void add(OutNetMessage msg) {
if (msg == null) return;
MessageSelector selector = msg.getReplySelector();
boolean valid = validate(msg);
if (!valid) {
_context.messageRegistry().unregisterPending(msg);
if (selector != null)
_context.messageRegistry().unregisterPending(msg);
return;
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("Adding " + msg);
MessageSelector selector = msg.getReplySelector();
if (selector != null) {
_context.messageRegistry().registerPending(msg);
}
@@ -50,8 +52,10 @@ public class OutNetMessagePool {
return;
}
/**
* @param msg non-null
*/
private boolean validate(OutNetMessage msg) {
if (msg == null) return false;
if (msg.getMessage() == null) {
if (_log.shouldLog(Log.WARN))
_log.warn("Null message in the OutNetMessage - expired too soon");

View File

@@ -130,7 +130,7 @@ public class OutboundMessageRegistry {
OutNetMessage msg = null;
List<OutNetMessage> msgs = null;
synchronized (_selectorToMessage) {
Object o = null;
Object o;
if ( (removedSelectors != null) && (removedSelectors.contains(sel)) ) {
o = _selectorToMessage.remove(sel);
removed = true;
@@ -229,7 +229,7 @@ public class OutboundMessageRegistry {
}
/**
* @param msg may be be null
* @param msg may be be null, if non-null should have a non-null selector
*/
@SuppressWarnings("unchecked")
public void unregisterPending(OutNetMessage msg) {