Permalink
Browse files

ISPN-7405 ProtobufMetadataInterceptor should use immortal metadata fo…

…r the .errors keys
  • Loading branch information...
1 parent 9c7e47a commit 694dd461e612415ad867e9c36914505da4bca039 @danberindei danberindei committed with anistor Jan 30, 2017
@@ -24,6 +24,8 @@
import org.infinispan.factories.annotations.Inject;
import org.infinispan.interceptors.AsyncInterceptorChain;
import org.infinispan.interceptors.BaseCustomAsyncInterceptor;
+import org.infinispan.metadata.EmbeddedMetadata;
+import org.infinispan.metadata.Metadata;
import org.infinispan.protostream.DescriptorParserException;
import org.infinispan.protostream.FileDescriptorSource;
import org.infinispan.protostream.SerializationContext;
@@ -39,6 +41,7 @@
* @since 7.0
*/
final class ProtobufMetadataManagerInterceptor extends BaseCustomAsyncInterceptor implements ProtobufMetadataManagerConstants {
+ private static final Metadata DEFAULT_METADATA = new EmbeddedMetadata.Builder().build();
private CommandsFactory commandsFactory;
@@ -79,7 +82,7 @@ private ProgressCallback(InvocationContext ctx, long flagsBitSet) {
public void handleError(String fileName, DescriptorParserException exception) {
// handle first error per file, ignore the rest if any
if (errorFiles.add(fileName)) {
- VisitableCommand cmd = commandsFactory.buildPutKeyValueCommand(fileName + ERRORS_KEY_SUFFIX, exception.getMessage(), null, flagsBitSet);
+ VisitableCommand cmd = commandsFactory.buildPutKeyValueCommand(fileName + ERRORS_KEY_SUFFIX, exception.getMessage(), DEFAULT_METADATA, flagsBitSet);
invoker.invoke(ctx, cmd);
}
}
@@ -326,16 +329,14 @@ public Object visitRemoveCommand(InvocationContext ctx, RemoveCommand command) t
sb.append('\n');
}
sb.append(fd.getName());
- PutKeyValueCommand put = commandsFactory.buildPutKeyValueCommand(fd.getName() + ERRORS_KEY_SUFFIX,
- "One of the imported files is missing or has errors",
- null, flagsBitSet);
+ PutKeyValueCommand put = commandsFactory.buildPutKeyValueCommand(fd.getName() + ERRORS_KEY_SUFFIX, "One of the imported files is missing or has errors", DEFAULT_METADATA, flagsBitSet);
put.setPutIfAbsent(true);
invoker.invoke(ctx, put);
}
}
if (sb.length() > 0) {
- cmd = commandsFactory.buildPutKeyValueCommand(ERRORS_KEY_SUFFIX, sb.toString(), null, flagsBitSet);
+ cmd = commandsFactory.buildPutKeyValueCommand(ERRORS_KEY_SUFFIX, sb.toString(), DEFAULT_METADATA, flagsBitSet);
} else {
cmd = commandsFactory.buildRemoveCommand(ERRORS_KEY_SUFFIX, null, flagsBitSet);
}
@@ -424,7 +425,7 @@ private void updateGlobalErrors(InvocationContext ctx, Set<String> errorFiles, l
}
sb.append(fileName);
}
- cmd = commandsFactory.buildPutKeyValueCommand(ERRORS_KEY_SUFFIX, sb.toString(), null, flagsBitSet);
+ cmd = commandsFactory.buildPutKeyValueCommand(ERRORS_KEY_SUFFIX, sb.toString(), DEFAULT_METADATA, flagsBitSet);
}
invoker.invoke(ctx, cmd);
}
@@ -1,6 +1,5 @@
package org.infinispan.query.remote.impl;
-import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertTrue;
import org.infinispan.Cache;
@@ -48,6 +47,8 @@ public void call() throws Exception {
public void call() throws Exception {
Cache<String, String> protobufMetadaCache = cms[0].getCache(ProtobufMetadataManagerConstants.PROTOBUF_METADATA_CACHE_NAME);
assertTrue(protobufMetadaCache.containsKey("testA.proto"));
+ assertTrue(protobufMetadaCache.containsKey("testB.proto"));
+ assertTrue(protobufMetadaCache.containsKey("testB.proto.errors"));
}
});
}

0 comments on commit 694dd46

Please sign in to comment.