Commit 3cef97cb authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

PiggyBackService: fixed null-pointer on piggyback-receive if no local

service is registered.
parent 5964bc4f
......@@ -99,7 +99,7 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
public static AvgAccumulatorTime _avgSendAndWaitTime = new AvgAccumulatorTime(
"Trans avg. SaW Delay", 1000);
public static AvgAccumulatorDouble _avgSendAndWaitSuccess = new AvgAccumulatorDouble(
"Trans avg. SaW Success", 1000);
......@@ -319,8 +319,7 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
for (PiggybackMessageService pService : piggybackServices
.values()) {
piggybacked = pService.piggybackOnSendMessage(receiverNet,
receiverPort,
ProtocolAdapter.this);
receiverPort, ProtocolAdapter.this);
if (piggybacked != null) {
if (mPig == null) {
mPig = new MessageWithPiggybackedData(msg);
......@@ -430,7 +429,6 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
}
}
/*
* Notify the Protocol of a received Message
*/
......@@ -465,7 +463,8 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
// triggered once
if (receivedMessage.getPayload() instanceof MessageWithPiggybackedData) {
MessageWithPiggybackedData pMsg = (MessageWithPiggybackedData) receivedMessage.getPayload();
MessageWithPiggybackedData pMsg = (MessageWithPiggybackedData) receivedMessage
.getPayload();
/*
* Deliver piggybacked messages
*/
......@@ -478,8 +477,8 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
// deliver real message
replyEvent.success(pMsg.getPayload(), senderInfo);
} else {
replyEvent
.success(receivedMessage.getPayload(), senderInfo);
replyEvent.success(receivedMessage.getPayload(),
senderInfo);
}
}
/*
......@@ -497,13 +496,15 @@ public class ModularTransLayer implements SimHostComponent, TransportComponent,
MessageWithPiggybackedData pMsg = (MessageWithPiggybackedData) receivedMessage
.getPayload();
/*
* Deliver piggybacked messages
* Deliver piggybacked messages, but only if we have a local
* listener. Discard otherwise.
*/
for (Entry<Byte, Message> entry : pMsg.getPiggybacked()
.entrySet()) {
piggybackServices.get(entry.getKey())
.onReceivedPiggybackedMessage(entry.getValue(),
senderInfo);
PiggybackMessageService service = piggybackServices.get(entry.getKey());
if (service != null) {
service.onReceivedPiggybackedMessage(entry.getValue(), senderInfo);
}
}
// deliver real message
pl.dispatch(pMsg.getPayload(), protocol, senderInfo,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment