Search in sources :

Example 71 with InvalidObjectException

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

the class JndiEncArtifact method readResolve.

public Object readResolve() throws ObjectStreamException {
    final ThreadContext thrdCntx = ThreadContext.getThreadContext();
    final BeanContext deployment = thrdCntx.getBeanContext();
    final Context cntx = deployment.getJndiEnc();
    try {
        final Object obj = cntx.lookup(path);
        if (obj == null) {
            throw new InvalidObjectException("JNDI ENC context reference could not be properly resolved when bean instance was activated");
        }
        return obj;
    } catch (final NamingException e) {
        throw (InvalidObjectException) new InvalidObjectException("JNDI ENC context reference could not be properly resolved due to a JNDI exception, when bean instance was activated").initCause(e);
    }
}
Also used : BeanContext(org.apache.openejb.BeanContext) Context(javax.naming.Context) ThreadContext(org.apache.openejb.core.ThreadContext) BeanContext(org.apache.openejb.BeanContext) ThreadContext(org.apache.openejb.core.ThreadContext) InvalidObjectException(java.io.InvalidObjectException) NamingException(javax.naming.NamingException)

Example 72 with InvalidObjectException

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

the class GridLoggerProxy 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, Object> t = stash.get();
        Object ctgrR = t.get2();
        IgniteLogger log = IgnitionEx.localIgnite().log();
        return ctgrR != null ? log.getLogger(ctgrR) : log;
    } catch (IllegalStateException e) {
        throw U.withCause(new InvalidObjectException(e.getMessage()), e);
    } finally {
        stash.remove();
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 73 with InvalidObjectException

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

the class SnapshotMetadata method readObject.

/**
 * Reconstitute the <tt>HashMap</tt> instance of partitions and cache groups from a stream.
 */
private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException {
    // Read in any hidden serialization.
    s.defaultReadObject();
    // Read size and verify non-negative.
    int size = s.readInt();
    if (size < 0)
        throw new InvalidObjectException("Illegal size: " + size);
    locParts = U.newHashMap(size);
    // Read in all elements in the proper order.
    for (int i = 0; i < size; i++) {
        int grpId = s.readInt();
        int total = s.readInt();
        if (total < 0)
            throw new InvalidObjectException("Illegal size: " + total);
        Set<Integer> parts = U.newHashSet(total);
        for (int k = 0; k < total; k++) parts.add(s.readInt());
        locParts.put(grpId, parts);
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 74 with InvalidObjectException

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

the class SensitiveInfoTestLoggerProxy 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, Object> t = stash.get();
        Object ctgrR = t.get2();
        IgniteLogger log = IgnitionEx.localIgnite().log();
        return ctgrR != null ? log.getLogger(ctgrR) : log;
    } catch (IllegalStateException e) {
        throw U.withCause(new InvalidObjectException(e.getMessage()), e);
    } finally {
        stash.remove();
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException) IgniteLogger(org.apache.ignite.IgniteLogger)

Example 75 with InvalidObjectException

use of java.io.InvalidObjectException in project j2objc by google.

the class TimeZoneFormat method readObject.

/**
 * @param ois the object input stream
 * @throws ClassNotFoundException
 * @throws IOException
 */
private void readObject(ObjectInputStream ois) throws ClassNotFoundException, IOException {
    ObjectInputStream.GetField fields = ois.readFields();
    _locale = (ULocale) fields.get("_locale", null);
    if (_locale == null) {
        throw new InvalidObjectException("Missing field: locale");
    }
    _tznames = (TimeZoneNames) fields.get("_tznames", null);
    if (_tznames == null) {
        throw new InvalidObjectException("Missing field: tznames");
    }
    _gmtPattern = (String) fields.get("_gmtPattern", null);
    if (_gmtPattern == null) {
        throw new InvalidObjectException("Missing field: gmtPattern");
    }
    String[] tmpGmtOffsetPatterns = (String[]) fields.get("_gmtOffsetPatterns", null);
    if (tmpGmtOffsetPatterns == null) {
        throw new InvalidObjectException("Missing field: gmtOffsetPatterns");
    } else if (tmpGmtOffsetPatterns.length < 4) {
        throw new InvalidObjectException("Incompatible field: gmtOffsetPatterns");
    }
    _gmtOffsetPatterns = new String[6];
    if (tmpGmtOffsetPatterns.length == 4) {
        for (int i = 0; i < 4; i++) {
            _gmtOffsetPatterns[i] = tmpGmtOffsetPatterns[i];
        }
        _gmtOffsetPatterns[GMTOffsetPatternType.POSITIVE_H.ordinal()] = truncateOffsetPattern(_gmtOffsetPatterns[GMTOffsetPatternType.POSITIVE_HM.ordinal()]);
        _gmtOffsetPatterns[GMTOffsetPatternType.NEGATIVE_H.ordinal()] = truncateOffsetPattern(_gmtOffsetPatterns[GMTOffsetPatternType.NEGATIVE_HM.ordinal()]);
    } else {
        _gmtOffsetPatterns = tmpGmtOffsetPatterns;
    }
    _gmtOffsetDigits = (String[]) fields.get("_gmtOffsetDigits", null);
    if (_gmtOffsetDigits == null) {
        throw new InvalidObjectException("Missing field: gmtOffsetDigits");
    } else if (_gmtOffsetDigits.length != 10) {
        throw new InvalidObjectException("Incompatible field: gmtOffsetDigits");
    }
    _gmtZeroFormat = (String) fields.get("_gmtZeroFormat", null);
    if (_gmtZeroFormat == null) {
        throw new InvalidObjectException("Missing field: gmtZeroFormat");
    }
    _parseAllStyles = fields.get("_parseAllStyles", false);
    if (fields.defaulted("_parseAllStyles")) {
        throw new InvalidObjectException("Missing field: parseAllStyles");
    }
    // instance.
    if (_tznames instanceof TimeZoneNamesImpl) {
        _tznames = TimeZoneNames.getInstance(_locale);
        // will be created by _locale later when necessary
        _gnames = null;
    } else {
        // Custom TimeZoneNames implementation is used. We need to create
        // a new instance of TimeZoneGenericNames here.
        _gnames = new TimeZoneGenericNames(_locale, _tznames);
    }
    // Transient fields requiring initialization
    initGMTPattern(_gmtPattern);
    initGMTOffsetPatterns(_gmtOffsetPatterns);
}
Also used : TimeZoneGenericNames(android.icu.impl.TimeZoneGenericNames) TimeZoneNamesImpl(android.icu.impl.TimeZoneNamesImpl) InvalidObjectException(java.io.InvalidObjectException) AttributedString(java.text.AttributedString) ObjectInputStream(java.io.ObjectInputStream)

Aggregations

InvalidObjectException (java.io.InvalidObjectException)88 ObjectInputStream (java.io.ObjectInputStream)18 IOException (java.io.IOException)15 ByteArrayInputStream (java.io.ByteArrayInputStream)7 SmallTest (android.test.suitebuilder.annotation.SmallTest)5 Rational (android.util.Rational)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 GwtIncompatible (com.google.common.annotations.GwtIncompatible)4 ObjectOutputStream (java.io.ObjectOutputStream)4 SimpleTimeZone (java.util.SimpleTimeZone)3 TimeZone (java.util.TimeZone)3 GwtIncompatible (com.google_voltpatches.common.annotations.GwtIncompatible)2 Point (java.awt.Point)2 File (java.io.File)2 RemoteObjectInvocationHandler (java.rmi.server.RemoteObjectInvocationHandler)2 RemoteRef (java.rmi.server.RemoteRef)2 Comparator (java.util.Comparator)2 CompositeData (javax.management.openmbean.CompositeData)2 IgniteLogger (org.apache.ignite.IgniteLogger)2 JSONObject (org.json.JSONObject)2