use of org.infinispan.commons.marshall.MarshallingException in project infinispan by infinispan.
the class LambdaMarshaller method read.
public static Object read(ObjectInput in, ClassLoader classLoader) throws ClassNotFoundException, IOException {
SerializedLambda sl = createSerializedLambda(in, classLoader);
try {
Class clazz = Class.forName(sl.getCapturingClass().replace("/", "."), true, classLoader);
Method method = SecurityActions.getMethodAndSetAccessible(clazz, "$deserializeLambda$", SerializedLambda.class);
return method.invoke(null, sl);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new MarshallingException(e);
}
}
use of org.infinispan.commons.marshall.MarshallingException in project infinispan by infinispan.
the class LambdaMarshaller method write.
static void write(ObjectOutput out, Object o) throws IOException {
try {
Method writeReplace = SecurityActions.getMethodAndSetAccessible(o, "writeReplace");
SerializedLambda sl = (SerializedLambda) writeReplace.invoke(o);
writeSerializedLambda(out, sl);
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new MarshallingException(e);
}
}
use of org.infinispan.commons.marshall.MarshallingException in project infinispan by infinispan.
the class ThrowableExternalizer method readGenericThrowable.
private Throwable readGenericThrowable(ObjectInput in) throws IOException, ClassNotFoundException {
String impl = in.readUTF();
String msg = MarshallUtil.unmarshallString(in);
Throwable t = (Throwable) in.readObject();
try {
Class<?> clazz = Class.forName(impl);
if (t == null && msg == null) {
return (Throwable) clazz.getConstructor().newInstance(new Object[] {});
} else if (t == null) {
return (Throwable) clazz.getConstructor(String.class).newInstance(msg);
} else if (msg == null) {
return (Throwable) clazz.getConstructor(Throwable.class).newInstance(t);
}
return (Throwable) clazz.getConstructor(String.class, Throwable.class).newInstance(msg, t);
} catch (IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException e) {
throw new MarshallingException(e);
}
}
use of org.infinispan.commons.marshall.MarshallingException in project infinispan by infinispan.
the class SingleOwnerTest method testRetrieveNonSerializableValueFromNonOwner.
public void testRetrieveNonSerializableValueFromNonOwner() {
Cache[] owners = getOwners("yourkey", 1);
Cache[] nonOwners = getNonOwners("yourkey", 1);
assert owners.length == 1;
assert nonOwners.length == 1;
Cache ownerCache = owners[0];
Cache nonOwnerCache = nonOwners[0];
ownerCache.put("yourkey", new Object());
try {
nonOwnerCache.get("yourkey");
fail("Should have failed with a org.infinispan.commons.marshall.MarshallingException");
} catch (RemoteException e) {
assertTrue(e.getCause() instanceof MarshallingException);
}
}
use of org.infinispan.commons.marshall.MarshallingException in project infinispan by infinispan.
the class NonBlockingSoftIndexFileStore method migrateFromOldFormat.
private void migrateFromOldFormat(FileProvider oldFileProvider) {
String cacheName = ctx.getCache().getName();
PERSISTENCE.startMigratingPersistenceData(cacheName);
try {
CompletionStages.join(index.clear());
} catch (CompletionException e) {
throw PERSISTENCE.persistedDataMigrationFailed(cacheName, e.getCause());
}
// Only update the key/value/meta bytes if the default marshaller is configured
boolean transformationRequired = ctx.getGlobalConfiguration().serialization().marshaller() == null;
try (CloseableIterator<Integer> it = oldFileProvider.getFileIterator()) {
while (it.hasNext()) {
int fileId = it.next();
try (FileProvider.Handle handle = oldFileProvider.getFile(fileId)) {
int offset = 0;
while (true) {
EntryHeader header = EntryRecord.readEntryHeader(handle, offset);
if (header == null) {
// end of file. go to next one
break;
}
MarshallableEntry<K, V> entry = readEntry(handle, header, offset, null, true, (key, value, meta, internalMeta, created, lastUsed) -> {
if (!transformationRequired) {
return marshallableEntryFactory.create(key, value, meta, internalMeta, created, lastUsed);
}
try {
Object k = unmarshallLegacy(key, false);
Object v = unmarshallLegacy(value, false);
Metadata m = unmarshallLegacy(meta, true);
PrivateMetadata im = internalMeta == null ? null : (PrivateMetadata) ctx.getPersistenceMarshaller().objectFromByteBuffer(internalMeta.getBuf());
return marshallableEntryFactory.create(k, v, m, im, created, lastUsed);
} catch (ClassNotFoundException | IOException e) {
throw new MarshallingException(e);
}
}, false);
int segment = keyPartitioner.getSegment(entry.getKey());
// noinspection ConstantConditions (entry is not null!)
if (entry.getValueBytes() != null) {
// using the storeQueue (instead of binary copy) to avoid building the index later
CompletionStages.join(logAppender.storeRequest(segment, entry));
} else {
// delete the entry. The file is append only so we can have a put() and later a remove() for the same key
CompletionStages.join(logAppender.deleteRequest(segment, entry.getKey(), entry.getKeyBytes()));
}
offset += header.totalLength();
}
}
// file is read. can be removed.
oldFileProvider.deleteFile(fileId);
}
PERSISTENCE.persistedDataSuccessfulMigrated(cacheName);
} catch (IOException e) {
throw PERSISTENCE.persistedDataMigrationFailed(cacheName, e);
}
}
Aggregations