Make entity object of event optional (#1209)
* explicitly return an optional entity by an event Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io> * fix assertions in tests Signed-off-by: Stefan Klotz <stefan.klotz@bosch.io>
This commit is contained in:
@@ -16,6 +16,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -303,8 +304,9 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
return;
|
||||
}
|
||||
|
||||
final Target target = cancelEvent.getEntity();
|
||||
if (target != null) {
|
||||
final Optional<Target> eventEntity = cancelEvent.getEntity();
|
||||
if (eventEntity.isPresent()) {
|
||||
final Target target = eventEntity.get();
|
||||
sendCancelMessageToTarget(cancelEvent.getTenant(), target.getControllerId(), cancelEvent.getActionId(),
|
||||
target.getAddress());
|
||||
} else {
|
||||
@@ -369,7 +371,8 @@ public class AmqpMessageDispatcherService extends BaseAmqpService {
|
||||
return;
|
||||
}
|
||||
|
||||
final Message message = new Message("".getBytes(), createConnectorMessagePropertiesDeleteThing(tenant, controllerId));
|
||||
final Message message = new Message("".getBytes(),
|
||||
createConnectorMessagePropertiesDeleteThing(tenant, controllerId));
|
||||
amqpSenderService.sendMessage(message, URI.create(targetAddress));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user