use of org.infinispan.util.KeyValuePair in project infinispan by infinispan.
the class ProtobufMetadataManagerInterceptor method visitRemoveCommand.
@Override
public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) {
if (!ctx.isOriginLocal()) {
return invokeNext(ctx, command);
}
if (!(command.getKey() instanceof String)) {
throw log.keyMustBeString(command.getKey().getClass());
}
String key = (String) command.getKey();
if (!shouldIntercept(key)) {
return invokeNext(ctx, command);
}
// lock global errors key
long flagsBitSet = copyFlags(command);
LockControlCommand lockCommand = commandsFactory.buildLockControlCommand(ERRORS_KEY_SUFFIX, flagsBitSet, null);
InvocationStage stage = invoker.running().invokeStage(ctx, lockCommand);
stage = stage.thenApplyMakeStage(ctx, command, (rCtx, rCommand, __) -> {
if (serializationContext.getFileDescriptors().containsKey(key)) {
serializationContext.unregisterProtoFile(key);
}
if (serializationContextRegistry.getUserCtx().getFileDescriptors().containsKey(key)) {
serializationContextRegistry.removeProtoFile(SerializationContextRegistry.MarshallerType.USER, key);
}
// put error key for all unresolved files and remove error key for all resolved files
// Error keys to be removed have a null value
List<KeyValuePair<String, String>> errorUpdates = computeErrorUpdatesAfterRemove(key);
return updateSchemaErrorsIterator(rCtx, flagsBitSet, errorUpdates.iterator());
});
return asyncInvokeNext(ctx, command, stage);
}
Aggregations