Search in sources :

Example 66 with InvalidObjectException

use of java.io.InvalidObjectException in project Bytecoder by mirkosertic.

the class DirectoryIteratorException method readObject.

/**
 * Called to read the object from a stream.
 *
 * @throws  InvalidObjectException
 *          if the object is invalid or has a cause that is not
 *          an {@code IOException}
 */
private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException {
    s.defaultReadObject();
    Throwable cause = super.getCause();
    if (!(cause instanceof IOException))
        throw new InvalidObjectException("Cause must be an IOException");
}
Also used : InvalidObjectException(java.io.InvalidObjectException) IOException(java.io.IOException)

Example 67 with InvalidObjectException

use of java.io.InvalidObjectException in project spf4j by zolyfarkas.

the class ExportedValuesMBean method setAttribute.

/**
 * {@inheritDoc}
 */
@Override
public void setAttribute(final Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException {
    String name = attribute.getName();
    ExportedValue<Object> result = (ExportedValue<Object>) exportedValues.get(name);
    if (result == null) {
        throw new AttributeNotFoundException(name);
    }
    try {
        result.set(attribute.getValue());
    } catch (InvalidObjectException | RuntimeException ex) {
        LOG.warn("Exception while setting attr {}", attribute, ex);
        throw new InvalidAttributeValueException("Invalid value " + attribute + " detail:\n" + Throwables.toString(ex));
    }
}
Also used : AttributeNotFoundException(javax.management.AttributeNotFoundException) JMRuntimeException(javax.management.JMRuntimeException) InvalidObjectException(java.io.InvalidObjectException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException)

Example 68 with InvalidObjectException

use of java.io.InvalidObjectException in project streamsupport by stefan-zobel.

the class ColSer method ioe.

private static InvalidObjectException ioe(RuntimeException ex) {
    InvalidObjectException ioe = new InvalidObjectException("invalid object");
    ioe.initCause(ex);
    return ioe;
}
Also used : InvalidObjectException(java.io.InvalidObjectException)

Example 69 with InvalidObjectException

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

the class RangeTest method testReadFields_Check.

public void testReadFields_Check() throws Exception {
    Range r = new Range(new Key(new Text("soup")), true, false, new Key(new Text("nuts")), true, false);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    r.write(dos);
    dos.close();
    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    Range r2 = new Range();
    try (DataInputStream dis = new DataInputStream(bais)) {
        r2.readFields(dis);
        fail("readFields allowed invalid range");
    } catch (InvalidObjectException exc) {
    /* good! */
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) DataOutputStream(java.io.DataOutputStream) Text(org.apache.hadoop.io.Text) InvalidObjectException(java.io.InvalidObjectException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TRange(org.apache.accumulo.core.data.thrift.TRange) DataInputStream(java.io.DataInputStream)

Example 70 with InvalidObjectException

use of java.io.InvalidObjectException in project hudson-2.x by hudson.

the class SimpleScheduledRetentionStrategy method readResolve.

protected synchronized Object readResolve() throws ObjectStreamException {
    try {
        tabs = CronTabList.create(startTimeSpec);
        lastChecked = new GregorianCalendar();
        this.lastChecked.add(Calendar.MINUTE, -1);
        nextStop = Long.MIN_VALUE;
        nextStart = Long.MIN_VALUE;
        lastStop = Long.MAX_VALUE;
        lastStart = Long.MAX_VALUE;
    } catch (ANTLRException e) {
        InvalidObjectException x = new InvalidObjectException(e.getMessage());
        x.initCause(e);
        throw x;
    }
    return this;
}
Also used : ANTLRException(antlr.ANTLRException) GregorianCalendar(java.util.GregorianCalendar) InvalidObjectException(java.io.InvalidObjectException)

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