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);
}
}
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);
}
}
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");
}
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));
}
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));
}
Aggregations