Search in sources :

Example 11 with InvalidObjectException

use of java.io.InvalidObjectException in project geode by apache.

the class OpenMethod method invokeWithOpenReturn.

Object invokeWithOpenReturn(Object obj, Object[] params) throws MBeanException, IllegalAccessException, InvocationTargetException {
    final Object[] javaParams;
    try {
        javaParams = fromOpenParameters(params);
    } catch (InvalidObjectException e) {
        final String msg = methodName() + ": cannot convert parameters " + "from open values: " + e;
        throw new MBeanException(e, msg);
    }
    final Object javaReturn = method.invoke(obj, javaParams);
    try {
        return returnTypeConverter.toOpenValue(javaReturn);
    } catch (OpenDataException e) {
        final String msg = methodName() + ": cannot convert return " + "value to open value: " + e;
        throw new MBeanException(e, msg);
    }
}
Also used : OpenDataException(javax.management.openmbean.OpenDataException) MBeanException(javax.management.MBeanException) InvalidObjectException(java.io.InvalidObjectException)

Example 12 with InvalidObjectException

use of java.io.InvalidObjectException in project geode by apache.

the class TableConverter method fromNonNullOpenValue.

public Object fromNonNullOpenValue(Object openValue) throws InvalidObjectException {
    final TabularData table = (TabularData) openValue;
    final Collection<CompositeData> rows = (Collection<CompositeData>) table.values();
    final Map<Object, Object> valueMap = sortedMap ? OpenTypeUtil.newSortedMap() : OpenTypeUtil.newMap();
    for (CompositeData row : rows) {
        final Object key = keyConverter.fromOpenValue(row.get("key"));
        final Object value = valueConverter.fromOpenValue(row.get("value"));
        if (valueMap.put(key, value) != null) {
            final String msg = "Duplicate entry in TabularData: key=" + key;
            throw new InvalidObjectException(msg);
        }
    }
    return valueMap;
}
Also used : CompositeData(javax.management.openmbean.CompositeData) Collection(java.util.Collection) InvalidObjectException(java.io.InvalidObjectException) TabularData(javax.management.openmbean.TabularData)

Example 13 with InvalidObjectException

use of java.io.InvalidObjectException in project ignite by apache.

the class GridCacheContext method readResolve.

/**
     * Reconstructs object on unmarshalling.
     *
     * @return Reconstructed object.
     * @throws ObjectStreamException Thrown in case of unmarshalling error.
     */
protected Object readResolve() throws ObjectStreamException {
    try {
        IgniteBiTuple<String, String> t = stash.get();
        IgniteKernal grid = IgnitionEx.localIgnite();
        GridCacheAdapter<K, V> cache = grid.internalCache(t.get2());
        if (cache == null)
            throw new IllegalStateException("Failed to find cache for name: " + t.get2());
        return cache.context();
    } catch (IllegalStateException e) {
        throw U.withCause(new InvalidObjectException(e.getMessage()), e);
    } finally {
        stash.remove();
    }
}
Also used : IgniteKernal(org.apache.ignite.internal.IgniteKernal) InvalidObjectException(java.io.InvalidObjectException)

Example 14 with InvalidObjectException

use of java.io.InvalidObjectException in project ignite by apache.

the class GridCacheSemaphoreImpl method readResolve.

/**
     * Reconstructs object on unmarshalling.
     *
     * @return Reconstructed object.
     * @throws ObjectStreamException Thrown in case of unmarshalling error.
     */
private Object readResolve() throws ObjectStreamException {
    try {
        IgniteBiTuple<GridKernalContext, String> t = stash.get();
        IgniteSemaphore sem = IgnitionEx.localIgnite().context().dataStructures().semaphore(t.get2(), 0, false, false);
        if (sem == null)
            throw new IllegalStateException("Semaphore was not found on deserialization: " + t.get2());
        return sem;
    } catch (IgniteCheckedException e) {
        throw U.withCause(new InvalidObjectException(e.getMessage()), e);
    } finally {
        stash.remove();
    }
}
Also used : IgniteCheckedException(org.apache.ignite.IgniteCheckedException) GridKernalContext(org.apache.ignite.internal.GridKernalContext) IgniteSemaphore(org.apache.ignite.IgniteSemaphore) InvalidObjectException(java.io.InvalidObjectException)

Example 15 with InvalidObjectException

use of java.io.InvalidObjectException in project jdk8u_jdk by JetBrains.

the class SimpleDateFormat method readObject.

/**
     * After reading an object from the input stream, the format
     * pattern in the object is verified.
     * <p>
     * @exception InvalidObjectException if the pattern is invalid
     */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    try {
        compiledPattern = compile(pattern);
    } catch (Exception e) {
        throw new InvalidObjectException("invalid pattern");
    }
    if (serialVersionOnStream < 1) {
        // didn't have defaultCenturyStart field
        initializeDefaultCentury();
    } else {
        // fill in dependent transient field
        parseAmbiguousDatesAsAfter(defaultCenturyStart);
    }
    serialVersionOnStream = currentSerialVersion;
    // If the deserialized object has a SimpleTimeZone, try
    // to replace it with a ZoneInfo equivalent in order to
    // be compatible with the SimpleTimeZone-based
    // implementation as much as possible.
    TimeZone tz = getTimeZone();
    if (tz instanceof SimpleTimeZone) {
        String id = tz.getID();
        TimeZone zi = TimeZone.getTimeZone(id);
        if (zi != null && zi.hasSameRules(tz) && zi.getID().equals(id)) {
            setTimeZone(zi);
        }
    }
}
Also used : TimeZone(java.util.TimeZone) SimpleTimeZone(java.util.SimpleTimeZone) SimpleTimeZone(java.util.SimpleTimeZone) InvalidObjectException(java.io.InvalidObjectException) IOException(java.io.IOException) InvalidObjectException(java.io.InvalidObjectException)

Aggregations

InvalidObjectException (java.io.InvalidObjectException)54 ObjectInputStream (java.io.ObjectInputStream)13 IOException (java.io.IOException)7 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Rational (android.util.Rational)5 GwtIncompatible (com.google.common.annotations.GwtIncompatible)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 ObjectOutputStream (java.io.ObjectOutputStream)3 GwtIncompatible (com.google_voltpatches.common.annotations.GwtIncompatible)2 Point (java.awt.Point)2 RemoteObjectInvocationHandler (java.rmi.server.RemoteObjectInvocationHandler)2 RemoteRef (java.rmi.server.RemoteRef)2 Comparator (java.util.Comparator)2 SimpleTimeZone (java.util.SimpleTimeZone)2 TimeZone (java.util.TimeZone)2 MBeanException (javax.management.MBeanException)2 OpenDataException (javax.management.openmbean.OpenDataException)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 ANTLRException (antlr.ANTLRException)1