use of org.apache.geode.SerializationException in project geode by apache.
the class InternalDataSerializer method readDataSerializable.
private static Object readDataSerializable(final DataInput in) throws IOException, ClassNotFoundException {
Class c = readClass(in);
try {
Constructor init = c.getConstructor(new Class[0]);
init.setAccessible(true);
Object o = init.newInstance(new Object[0]);
Assert.assertTrue(o instanceof DataSerializable);
invokeFromData(o, in);
if (logger.isTraceEnabled(LogMarker.SERIALIZER)) {
logger.trace(LogMarker.SERIALIZER, "Read DataSerializable {}", o);
}
return o;
} catch (EOFException ex) {
// client went away - ignore
throw ex;
} catch (Exception ex) {
throw new SerializationException(LocalizedStrings.DataSerializer_COULD_NOT_CREATE_AN_INSTANCE_OF_0.toLocalizedString(c.getName()), ex);
}
}
use of org.apache.geode.SerializationException in project geode by apache.
the class BaseCommand method execute.
@Override
public void execute(Message clientMessage, ServerConnection serverConnection) {
// Read the request and update the statistics
long start = DistributionStats.getStatTime();
if (EntryLogger.isEnabled() && serverConnection != null) {
EntryLogger.setSource(serverConnection.getMembershipID(), "c2s");
}
boolean shouldMasquerade = shouldMasqueradeForTx(clientMessage, serverConnection);
try {
if (shouldMasquerade) {
InternalCache cache = serverConnection.getCache();
InternalDistributedMember member = (InternalDistributedMember) serverConnection.getProxyID().getDistributedMember();
TXManagerImpl txMgr = cache.getTxManager();
TXStateProxy tx = null;
try {
tx = txMgr.masqueradeAs(clientMessage, member, false);
cmdExecute(clientMessage, serverConnection, start);
tx.updateProxyServer(txMgr.getMemberId());
} finally {
txMgr.unmasquerade(tx);
}
} else {
cmdExecute(clientMessage, serverConnection, start);
}
} catch (TransactionException | CopyException | SerializationException | CacheWriterException | CacheLoaderException | GemFireSecurityException | PartitionOfflineException | MessageTooLargeException e) {
handleExceptionNoDisconnect(clientMessage, serverConnection, e);
} catch (EOFException eof) {
BaseCommand.handleEOFException(clientMessage, serverConnection, eof);
} catch (InterruptedIOException e) {
// Solaris only
BaseCommand.handleInterruptedIOException(serverConnection, e);
} catch (IOException e) {
BaseCommand.handleIOException(clientMessage, serverConnection, e);
} catch (DistributedSystemDisconnectedException e) {
BaseCommand.handleShutdownException(clientMessage, serverConnection, e);
} catch (VirtualMachineError err) {
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable e) {
BaseCommand.handleThrowable(clientMessage, serverConnection, e);
} finally {
EntryLogger.clearSource();
}
}
use of org.apache.geode.SerializationException in project geode by apache.
the class Message method serializeAndAddPart.
private void serializeAndAddPart(Object o, boolean zipValues) {
if (zipValues) {
throw new UnsupportedOperationException("zipValues no longer supported");
}
Version v = this.version;
if (this.version.equals(Version.CURRENT)) {
v = null;
}
// do NOT close the HeapDataOutputStream
HeapDataOutputStream hdos = new HeapDataOutputStream(this.chunkSize, v);
try {
BlobHelper.serializeTo(o, hdos);
} catch (IOException ex) {
throw new SerializationException("failed serializing object", ex);
}
this.messageModified = true;
Part part = this.partsList[this.currentPart];
part.setPartState(hdos, true);
this.currentPart++;
}
use of org.apache.geode.SerializationException in project geode by apache.
the class Message method serializeAndAddPartNoCopying.
private void serializeAndAddPartNoCopying(Object o) {
Version v = this.version;
if (this.version.equals(Version.CURRENT)) {
v = null;
}
// Create the HDOS with a flag telling it that it can keep any byte[] or ByteBuffers/ByteSources
// passed to it. Do NOT close the HeapDataOutputStream!
HeapDataOutputStream hdos = new HeapDataOutputStream(this.chunkSize, v, true);
try {
BlobHelper.serializeTo(o, hdos);
} catch (IOException ex) {
throw new SerializationException("failed serializing object", ex);
}
this.messageModified = true;
Part part = this.partsList[this.currentPart];
part.setPartState(hdos, true);
this.currentPart++;
}
use of org.apache.geode.SerializationException in project geode by apache.
the class InternalDataSerializer method readUserDataSerializable.
private static Object readUserDataSerializable(final DataInput in, int classId) throws IOException {
Instantiator instantiator = InternalInstantiator.getInstantiator(classId);
if (instantiator == null) {
logger.error(LogMarker.SERIALIZER, LocalizedMessage.create(LocalizedStrings.DataSerializer_NO_INSTANTIATOR_HAS_BEEN_REGISTERED_FOR_CLASS_WITH_ID_0, classId));
throw new IOException(LocalizedStrings.DataSerializer_NO_INSTANTIATOR_HAS_BEEN_REGISTERED_FOR_CLASS_WITH_ID_0.toLocalizedString(classId));
} else {
try {
DataSerializable ds;
if (instantiator instanceof CanonicalInstantiator) {
CanonicalInstantiator ci = (CanonicalInstantiator) instantiator;
ds = ci.newInstance(in);
} else {
ds = instantiator.newInstance();
}
ds.fromData(in);
return ds;
} catch (Exception ex) {
throw new SerializationException(LocalizedStrings.DataSerializer_COULD_NOT_DESERIALIZE_AN_INSTANCE_OF_0.toLocalizedString(instantiator.getInstantiatedClass().getName()), ex);
}
}
}
Aggregations