public void update(OutputContext context) {
log.debug(String.format("%s - Output context changed, updating ports", this));
// Copy the context in order to ensure that future changes via the
// observer will not effect this update.
final OutputContext update = context.copy();
// All updates are run sequentially to prevent race conditions
// during configuration changes. Without essentially locking the
// object, it could be possible that connections are simultaneously
// added and removed or opened and closed on the object.
tasks.runTask(new Handler<Task>() {
@Override
public void handle(final Task task) {
final List<OutputPort> newPorts = new ArrayList<>();
for (OutputPortContext output : update.ports()) {
if (!ports.containsKey(output.name())) {
OutputPortContext port = DefaultOutputCollector.this.context.port(output.name());
if (port != null) {
log.debug(String.format("%s - Adding out port: %s", DefaultOutputCollector.this, output));
newPorts.add(new DefaultOutputPort(vertx, port));