Search in sources :

Example 26 with InvalidObjectException

use of java.io.InvalidObjectException in project ddf by codice.

the class MetacardImpl method readObject.

/**
     * Deserializes this {@link MetacardImpl}'s instance.
     *
     * @param stream the {@link ObjectInputStream} that contains the bytes of the object
     * @throws IOException
     * @throws ClassNotFoundException
     */
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    /*
         * defaultReadObject() is invoked for greater flexibility and compatibility. See the
         * *Serialization Note* in MetacardImpl's class Javadoc.
         */
    stream.defaultReadObject();
    map = new HashMap<String, Attribute>();
    wrappedMetacard = null;
    type = (MetacardType) stream.readObject();
    if (type == null) {
        throw new InvalidObjectException(MetacardType.class.getName() + " instance cannot be null.");
    }
    int numElements = stream.readInt();
    for (int i = 0; i < numElements; i++) {
        Attribute attribute = (Attribute) stream.readObject();
        if (attribute != null) {
            AttributeDescriptor attributeDescriptor = getMetacardType().getAttributeDescriptor(attribute.getName());
            if (attributeDescriptor != null && attribute.getValue() != null) {
                attributeDescriptor.getType().getAttributeFormat();
                attributeDescriptor.getType().getClass();
            }
        }
        setAttribute(attribute);
    }
}
Also used : Attribute(ddf.catalog.data.Attribute) AttributeDescriptor(ddf.catalog.data.AttributeDescriptor) InvalidObjectException(java.io.InvalidObjectException)

Example 27 with InvalidObjectException

use of java.io.InvalidObjectException in project bazel by bazelbuild.

the class CompactHashSet method readObject.

@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    int length = stream.readInt();
    float loadFactor = stream.readFloat();
    int elementCount = stream.readInt();
    try {
        init(length, loadFactor);
    } catch (IllegalArgumentException e) {
        throw new InvalidObjectException(e.getMessage());
    }
    for (int i = elementCount; --i >= 0; ) {
        E element = (E) stream.readObject();
        add(element);
    }
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 28 with InvalidObjectException

use of java.io.InvalidObjectException in project fqrouter by fqrouter.

the class DNSName method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    byte[] bytes;
    if ((bytes = this.bytes) == null)
        throw new InvalidObjectException("bytes: null");
    if (bytes.length <= 0 || lengthOf(bytes, 0) != bytes.length)
        throw new InvalidObjectException("Bad resource name");
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 29 with InvalidObjectException

use of java.io.InvalidObjectException in project fqrouter by fqrouter.

the class DNSRecord method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    DNSName rName;
    byte[] rDataBytes;
    if ((rName = this.rName) == null)
        throw new InvalidObjectException("rName: null");
    if ((rDataBytes = this.rDataBytes) == null)
        throw new InvalidObjectException("rDataBytes: null");
    if ((rDataBytes.length & ~RDATA_LEN_MASK) != 0)
        throw new InvalidObjectException("rDataBytes length: " + UnsignedInt.toString(rDataBytes.length, false));
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 30 with InvalidObjectException

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

the class ImmutableSetMultimap method readObject.

// java.io.ObjectInputStream
@GwtIncompatible
// Serialization type safety is at the caller's mercy.
@SuppressWarnings("unchecked")
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException {
    stream.defaultReadObject();
    Comparator<Object> valueComparator = (Comparator<Object>) stream.readObject();
    int keyCount = stream.readInt();
    if (keyCount < 0) {
        throw new InvalidObjectException("Invalid key count " + keyCount);
    }
    ImmutableMap.Builder<Object, ImmutableSet<Object>> builder = ImmutableMap.builder();
    int tmpSize = 0;
    for (int i = 0; i < keyCount; i++) {
        Object key = stream.readObject();
        int valueCount = stream.readInt();
        if (valueCount <= 0) {
            throw new InvalidObjectException("Invalid value count " + valueCount);
        }
        ImmutableSet.Builder<Object> valuesBuilder = valuesBuilder(valueComparator);
        for (int j = 0; j < valueCount; j++) {
            valuesBuilder.add(stream.readObject());
        }
        ImmutableSet<Object> valueSet = valuesBuilder.build();
        if (valueSet.size() != valueCount) {
            throw new InvalidObjectException("Duplicate key-value pairs exist for key " + key);
        }
        builder.put(key, valueSet);
        tmpSize += valueCount;
    }
    ImmutableMap<Object, ImmutableSet<Object>> tmpMap;
    try {
        tmpMap = builder.build();
    } catch (IllegalArgumentException e) {
        throw (InvalidObjectException) new InvalidObjectException(e.getMessage()).initCause(e);
    }
    FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
    FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
    FieldSettersHolder.EMPTY_SET_FIELD_SETTER.set(this, emptySet(valueComparator));
}
Also used : InvalidObjectException(java.io.InvalidObjectException) Comparator(java.util.Comparator) GwtIncompatible(com.google.common.annotations.GwtIncompatible)

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