Search in sources :

Example 6 with SerializationException

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);
    }
}
Also used : SerializationException(org.apache.geode.SerializationException) Constructor(java.lang.reflect.Constructor) EOFException(java.io.EOFException) ObjectStreamClass(java.io.ObjectStreamClass) DataSerializable(org.apache.geode.DataSerializable) InvocationTargetException(java.lang.reflect.InvocationTargetException) NonPortableClassException(org.apache.geode.pdx.NonPortableClassException) IOException(java.io.IOException) CancelException(org.apache.geode.CancelException) EOFException(java.io.EOFException) UTFDataFormatException(java.io.UTFDataFormatException) GemFireIOException(org.apache.geode.GemFireIOException) SerializationException(org.apache.geode.SerializationException) CacheClosedException(org.apache.geode.cache.CacheClosedException) NotSerializableException(java.io.NotSerializableException) ToDataException(org.apache.geode.ToDataException)

Example 7 with SerializationException

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();
    }
}
Also used : InterruptedIOException(java.io.InterruptedIOException) CopyException(org.apache.geode.CopyException) DistributedSystemDisconnectedException(org.apache.geode.distributed.DistributedSystemDisconnectedException) TXManagerImpl(org.apache.geode.internal.cache.TXManagerImpl) SerializationException(org.apache.geode.SerializationException) InternalCache(org.apache.geode.internal.cache.InternalCache) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) TransactionException(org.apache.geode.cache.TransactionException) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) PartitionOfflineException(org.apache.geode.cache.persistence.PartitionOfflineException) TXStateProxy(org.apache.geode.internal.cache.TXStateProxy) CacheLoaderException(org.apache.geode.cache.CacheLoaderException) EOFException(java.io.EOFException) CacheWriterException(org.apache.geode.cache.CacheWriterException)

Example 8 with SerializationException

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++;
}
Also used : SerializationException(org.apache.geode.SerializationException) Version(org.apache.geode.internal.Version) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) IOException(java.io.IOException)

Example 9 with SerializationException

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++;
}
Also used : SerializationException(org.apache.geode.SerializationException) Version(org.apache.geode.internal.Version) HeapDataOutputStream(org.apache.geode.internal.HeapDataOutputStream) IOException(java.io.IOException)

Example 10 with SerializationException

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);
        }
    }
}
Also used : CanonicalInstantiator(org.apache.geode.CanonicalInstantiator) SerializationException(org.apache.geode.SerializationException) CanonicalInstantiator(org.apache.geode.CanonicalInstantiator) Instantiator(org.apache.geode.Instantiator) IOException(java.io.IOException) GemFireIOException(org.apache.geode.GemFireIOException) DataSerializable(org.apache.geode.DataSerializable) InvocationTargetException(java.lang.reflect.InvocationTargetException) NonPortableClassException(org.apache.geode.pdx.NonPortableClassException) IOException(java.io.IOException) CancelException(org.apache.geode.CancelException) EOFException(java.io.EOFException) UTFDataFormatException(java.io.UTFDataFormatException) GemFireIOException(org.apache.geode.GemFireIOException) SerializationException(org.apache.geode.SerializationException) CacheClosedException(org.apache.geode.cache.CacheClosedException) NotSerializableException(java.io.NotSerializableException) ToDataException(org.apache.geode.ToDataException)

Aggregations

SerializationException (org.apache.geode.SerializationException)11 IOException (java.io.IOException)7 EOFException (java.io.EOFException)5 NotSerializableException (java.io.NotSerializableException)4 UTFDataFormatException (java.io.UTFDataFormatException)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 CancelException (org.apache.geode.CancelException)4 GemFireIOException (org.apache.geode.GemFireIOException)4 ToDataException (org.apache.geode.ToDataException)4 CacheClosedException (org.apache.geode.cache.CacheClosedException)4 NonPortableClassException (org.apache.geode.pdx.NonPortableClassException)4 ObjectStreamClass (java.io.ObjectStreamClass)3 DataSerializable (org.apache.geode.DataSerializable)3 HeapDataOutputStream (org.apache.geode.internal.HeapDataOutputStream)3 Constructor (java.lang.reflect.Constructor)2 CacheLoaderException (org.apache.geode.cache.CacheLoaderException)2 Region (org.apache.geode.cache.Region)2 Version (org.apache.geode.internal.Version)2 DataTypeNotSupportedException (org.apache.geode.rest.internal.web.exception.DataTypeNotSupportedException)2 JSONObject (org.json.JSONObject)2