Java 类java.io.NotSerializableException 实例源码

项目:neoscada    文件:ObjectSerializationProtocol.java   
@Override
public DataMessage encodeMessage ( final Object message ) throws Exception
{
    if ( ! ( message instanceof Serializable ) )
    {
        if ( message != null )
        {
            throw new NotSerializableException ( message.getClass ().getName () );
        }
        else
        {
            throw new NotSerializableException ();
        }
    }

    final IoBuffer data = IoBuffer.allocate ( 64 );
    data.setAutoExpand ( true );
    data.putObject ( message );
    data.flip ();
    return new DataMessage ( data );
}
项目:neoscada    文件:ObjectSerializationEncoder.java   
public void encode(IoSession session, Object message, ProtocolEncoderOutput out) throws Exception {
    if (!(message instanceof Serializable)) {
        throw new NotSerializableException();
    }

    IoBuffer buf = IoBuffer.allocate(64);
    buf.setAutoExpand(true);
    buf.putObject(message);

    int objectSize = buf.position() - 4;
    if (objectSize > maxObjectSize) {
        throw new IllegalArgumentException("The encoded object is too big: " + objectSize + " (> " + maxObjectSize
                + ')');
    }

    buf.flip();
    out.write(buf);
}
项目:openjdk-systemtest    文件:HashtableTest.java   
private void doSerializationTest(Map<Object,Object> table) {
    byte[] bytes = null;
    Object in = null;

    // write out object
    try {
        bytes = writeOutObject(table);
    } catch (NotSerializableException e) {
        fail("Expected object " + table + " to be serializable");
    }

    // read object back in
    in = bytesToObject(bytes);

    // compare object
    assertEquals("Comparison failed for test " + table,
            table, in);
}
项目:hekate    文件:FstCodec.java   
@Override
public void encode(Object obj, DataWriter out) throws IOException {
    try {
        FSTObjectOutput objOut = fst.getObjectOutput(out.asStream());

        objOut.writeObject(obj);
        objOut.flush();
    } catch (RuntimeException e) {
        // Workaround for FST throwing RuntimeException instead of NotSerializableException.
        if (e.getMessage() != null && e.getMessage().indexOf("does not implement Serializable") > 0) {
            NotSerializableException converted = new NotSerializableException(e.getMessage());

            converted.setStackTrace(e.getStackTrace());

            throw converted;
        } else {
            throw e;
        }
    }
}
项目:hekate    文件:RpcUnicastTest.java   
@Test
public void testNonSerializableArg() throws Exception {
    TestRpcC rpc = mock(TestRpcC.class);

    HekateTestNode client = prepareClientAndServer(rpc).client();

    TestRpcC proxy = client.rpc().clientFor(TestRpcC.class).build();

    repeat(3, i -> {
        RpcException err = expect(RpcException.class, () -> proxy.callC(1, new NonSerializable()));

        String stackTrace = ErrorUtils.stackTrace(err);

        assertTrue(stackTrace, ErrorUtils.isCausedBy(CodecException.class, err));
        assertTrue(stackTrace, stackTrace.contains(NotSerializableException.class.getName()));
        assertTrue(stackTrace, stackTrace.contains(Socket.class.getName()));

        verifyNoMoreInteractions(rpc);
        reset(rpc);
    });
}
项目:hekate    文件:RpcUnicastTest.java   
@Test
public void testNonSerializableResult() throws Exception {
    TestRpcB rpc = mock(TestRpcB.class);

    HekateTestNode client = prepareClientAndServer(rpc).client();

    TestRpcB proxy = client.rpc().clientFor(TestRpcB.class).build();

    repeat(3, i -> {
        when(rpc.callB()).thenReturn(new NonSerializable());

        RpcException err = expect(RpcException.class, proxy::callB);

        String stackTrace = ErrorUtils.stackTrace(err);

        assertTrue(stackTrace, ErrorUtils.isCausedBy(MessagingRemoteException.class, err));
        assertTrue(stackTrace, stackTrace.contains(NotSerializableException.class.getName()));
        assertTrue(stackTrace, stackTrace.contains(Socket.class.getName()));

        verify(rpc).callB();
        verifyNoMoreInteractions(rpc);
        reset(rpc);
    });
}
项目:hekate    文件:MessagingChannelRequestTest.java   
@Test
public void testNonSerializableRequest() throws Exception {
    HekateTestNode sender = prepareObjectSenderAndReceiver(msg ->
        msg.reply("OK")
    );

    repeat(5, i -> {
        MessagingFutureException err = expect(MessagingFutureException.class, () ->
            get(sender.messaging().channel("test").forRemotes().request(new NonSerializable()))
        );

        assertSame(err.toString(), MessagingException.class, err.getCause().getClass());
        assertTrue(err.isCausedBy(CodecException.class));
        assertTrue(err.isCausedBy(NotSerializableException.class));
    });
}
项目:OpenJSharp    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:monarch    文件:SearchLoadAndWriteProcessor.java   
/**
 * Using a new or pooled message instance, create and send the request for object value to the
 * specified node.
 */
public static void sendMessage(SearchLoadAndWriteProcessor processor, String regionName,
    Object key, Object aCallbackArgument, InternalDistributedMember recipient, int timeoutMs,
    int ttl, int idleTime) {

  // create a message
  NetLoadRequestMessage msg = new NetLoadRequestMessage();
  msg.initialize(processor, regionName, key, aCallbackArgument, timeoutMs, ttl, idleTime);
  msg.setRecipient(recipient);

  try {
    processor.distributionManager.putOutgoingUserData(msg);
  } catch (NotSerializableException e) {
    throw new IllegalArgumentException(
        LocalizedStrings.SearchLoadAndWriteProcessor_MESSAGE_NOT_SERIALIZABLE
            .toLocalizedString());
  }
}
项目:monarch    文件:FunctionStreamingReplyMessage.java   
@Override
public void fromData(DataInput in) throws IOException, ClassNotFoundException {
  super.fromData(in);
  this.msgNum = in.readInt();
  this.lastMsg = in.readBoolean();
  this.processorId = in.readInt();
  try {
    this.result = DataSerializer.readObject(in);
  } catch (Exception e) { // bug fix 40670
    // Seems odd to throw a NonSerializableEx when it has already been
    // serialized and we are failing because we can't deserialize.
    NotSerializableException ioEx = new NotSerializableException();
    ioEx.initCause(e);
    throw ioEx;
  }
}
项目:monarch    文件:NotAuthorizedExceptionTest.java   
private void assertPreconditions() {
  catchException(this).clone(this.nonSerializableNamingException);
  assertThat((Throwable) caughtException()).isNotNull();
  assertThat((Throwable) caughtException().getCause())
      .isInstanceOf(NotSerializableException.class);

  catchException(this).clone(this.serializableNamingException);
  assertThat((Throwable) caughtException()).isNull();

  assertThat(this.nonSerializableResolvedObj).isNotInstanceOf(Serializable.class);

  catchException(this).clone(this.serializableResolvedObj);
  assertThat((Throwable) caughtException()).isNull();

  assertThat(this.nonSerializablePrincipal).isNotInstanceOf(Serializable.class);

  catchException(this).clone(this.serializablePrincipal);
  assertThat((Throwable) caughtException()).isNull();
}
项目:monarch    文件:PdxSerializableJUnitTest.java   
@Test
public void testBasicAll() throws IOException, ClassNotFoundException {
  BasicAllFieldTypes v1 = new BasicAllFieldTypes(0x1020304050607080L, false);
  try {
    serializeAndDeserialize(v1);
    throw new RuntimeException("expected NotSerializableException");
  } catch (NotSerializableException expected) {

  }
  this.c.setPdxSerializer(new BasicAllFieldTypesPdxSerializer());
  try {
    BasicAllFieldTypes v2 = (BasicAllFieldTypes) serializeAndDeserialize(v1);
    assertEquals(v1, v2);
  } finally {
    this.c.setPdxSerializer(null);
  }
}
项目:monarch    文件:PdxSerializableJUnitTest.java   
@Test
public void testBasicAllWithNulls() throws IOException, ClassNotFoundException {
  BasicAllFieldTypes v1 = new BasicAllFieldTypes(0x1020304050607080L, true);
  try {
    serializeAndDeserialize(v1);
    throw new RuntimeException("expected NotSerializableException");
  } catch (NotSerializableException expected) {

  }
  this.c.setPdxSerializer(new BasicAllFieldTypesPdxSerializer());
  try {
    BasicAllFieldTypes v2 = (BasicAllFieldTypes) serializeAndDeserialize(v1);
    assertEquals(v1, v2);
  } finally {
    this.c.setPdxSerializer(null);
  }
}
项目:jdk8u-jdk    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        throw ioe; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    } else if (ioe instanceof MarshalException) {
        // IIOP will throw MarshalException wrapping a NotSerializableException
        // when a server fails to serialize a response.
        MarshalException me = (MarshalException)ioe;
        if (me.detail instanceof NotSerializableException) {
            throw (NotSerializableException)me.detail;
        }
    }

    // Not serialization problem, return.
}
项目:KeYExperienceReport    文件:Client.java   
public Client(final String ip, int port) throws UnknownHostException,
        IOException, ClassNotFoundException {
    Socket socket = new Socket(ip, port);
    ObjectOutputStream outToClient = new ObjectOutputStream(
            socket.getOutputStream());
    ObjectInputStream inFromClient = new ObjectInputStream(
            socket.getInputStream());

    long startTime = System.currentTimeMillis();
    long currentTime = System.currentTimeMillis();
    while (socket.isConnected() && jobs < MAX_JOBS
            && (currentTime - startTime) < MAX_RUNTIME) {
        jobs++;
        ResultRunnable job = (ResultRunnable) inFromClient.readObject();
        job.setIPAdress(ip);
        job.run();
        Object result = job.getResult();
        try {
            outToClient.writeObject(result);
        } catch (NotSerializableException e) {
            outToClient.writeObject(e);
        }
        currentTime = System.currentTimeMillis();
    }

    if (!socket.isClosed()) {
        restart = true;
    }

    socket.close();
}
项目:jrpip    文件:ErrorConditionsTest.java   
public void testFastFailWhenArgumentsCannotBeSerialized() throws Exception
{
    this.setupServerWithHandler(null);
    Echo echo = this.buildEchoProxy();
    try
    {
        echo.echoObject(new Object());
        Assert.fail();
    }
    catch (JrpipRuntimeException e)
    {
        assertTrue(e.getCause() instanceof NotSerializableException);
    }
}
项目:akka-persistance-ignite    文件:IgniteWriteJournal.java   
/**
 * @param config akka configuration
 * @throws NotSerializableException
 */
public IgniteWriteJournal(Config config) throws NotSerializableException {
    ActorSystem actorSystem = context().system();
    serializer = SerializationExtension.get(actorSystem).serializerFor(PersistentRepr.class);
    storage = new Store<>(actorSystem);
    JournalCaches journalCaches = journalCacheProvider.apply(config, actorSystem);
    sequenceNumberTrack = journalCaches.getSequenceCache();
    cache = journalCaches.getJournalCache();
}
项目:lams    文件:DefaultListableBeanFactory.java   
protected Object writeReplace() throws ObjectStreamException {
    if (this.serializationId != null) {
        return new SerializedBeanFactoryReference(this.serializationId);
    }
    else {
        throw new NotSerializableException("DefaultListableBeanFactory has no serialization id");
    }
}
项目:lams    文件:AbstractPrototypeBasedTargetSource.java   
/**
 * Replaces this object with a SingletonTargetSource on serialization.
 * Protected as otherwise it won't be invoked for subclasses.
 * (The {@code writeReplace()} method must be visible to the class
 * being serialized.)
 * <p>With this implementation of this method, there is no need to mark
 * non-serializable fields in this class or subclasses as transient.
 */
protected Object writeReplace() throws ObjectStreamException {
    if (logger.isDebugEnabled()) {
        logger.debug("Disconnecting TargetSource [" + this + "]");
    }
    try {
        // Create disconnected SingletonTargetSource.
        return new SingletonTargetSource(getTarget());
    }
    catch (Exception ex) {
        logger.error("Cannot get target for disconnecting TargetSource [" + this + "]", ex);
        throw new NotSerializableException(
                "Cannot get target for disconnecting TargetSource [" + this + "]: " + ex);
    }
}
项目:lams    文件:AbstractEntityManagerFactoryBean.java   
protected Object writeReplace() throws ObjectStreamException {
    if (this.beanFactory != null && this.beanName != null) {
        return new SerializedEntityManagerFactoryBeanReference(this.beanFactory, this.beanName);
    }
    else {
        throw new NotSerializableException("EntityManagerFactoryBean does not run within a BeanFactory");
    }
}
项目:skript-mirror    文件:Types.java   
@Override
protected JavaType deserialize(Fields fields) throws StreamCorruptedException,
    NotSerializableException {
  try {
    return new JavaType(LibraryLoader.getClassLoader().loadClass((String) fields.getObject("type")));
  } catch (ClassNotFoundException e) {
    throw new NotSerializableException();
  }
}
项目:openjdk-jdk10    文件:TemplatesImpl.java   
/**
 *  This is to fix bugzilla bug 22438
 *  If the user defined class implements URIResolver and Serializable
 *  then we want it to get serialized
 */
private void writeObject(ObjectOutputStream os)
    throws IOException, ClassNotFoundException {
    if (_auxClasses != null) {
        //throw with the same message as when Hashtable was used for compatibility.
        throw new NotSerializableException(
                "com.sun.org.apache.xalan.internal.xsltc.runtime.Hashtable");
    }

    // Write serialized fields
    ObjectOutputStream.PutField pf = os.putFields();
    pf.put("_name", _name);
    pf.put("_bytecodes", _bytecodes);
    pf.put("_class", _class);
    pf.put("_transletIndex", _transletIndex);
    pf.put("_outputProperties", _outputProperties);
    pf.put("_indentNumber", _indentNumber);
    os.writeFields();

    if (_uriResolver instanceof Serializable) {
        os.writeBoolean(true);
        os.writeObject((Serializable) _uriResolver);
    }
    else {
        os.writeBoolean(false);
    }
}
项目:OpenJSharp    文件:CertPath.java   
/**
 * Returns a {@code CertPath} constructed from the type and data.
 *
 * @return the resolved {@code CertPath} object
 *
 * @throws ObjectStreamException if a {@code CertPath} could not
 * be constructed
 */
protected Object readResolve() throws ObjectStreamException {
    try {
        CertificateFactory cf = CertificateFactory.getInstance(type);
        return cf.generateCertPath(new ByteArrayInputStream(data));
    } catch (CertificateException ce) {
        NotSerializableException nse =
            new NotSerializableException
                ("java.security.cert.CertPath: " + type);
        nse.initCause(ce);
        throw nse;
    }
}
项目:OpenJSharp    文件:ClientNotifForwarder.java   
private NotificationResult fetchNotifs() {
    try {
        NotificationResult nr = ClientNotifForwarder.this.
            fetchNotifs(clientSequenceNumber,maxNotifications,
                        timeout);

        if (logger.traceOn()) {
            logger.trace("NotifFetcher-run",
                         "Got notifications from the server: "+nr);
        }

        return nr;
    } catch (ClassNotFoundException | NotSerializableException | UnmarshalException e) {
        logger.trace("NotifFetcher.fetchNotifs", e);
        return fetchOneNotif();
    } catch (IOException ioe) {
        if (!shouldStop()) {
            logger.error("NotifFetcher-run",
                         "Failed to fetch notification, " +
                         "stopping thread. Error is: " + ioe, ioe);
            logger.debug("NotifFetcher-run",ioe);
        }

        // no more fetching
        return null;
    }
}
项目:openjdk-jdk10    文件:CClipboard.java   
@Override
protected void setContentsNative(Transferable contents) {
    FlavorTable flavorMap = getDefaultFlavorTable();
    // Don't use delayed Clipboard rendering for the Transferable's data.
    // If we did that, we would call Transferable.getTransferData on
    // the Toolkit thread, which is a security hole.
    //
    // Get all of the target formats into which the Transferable can be
    // translated. Then, for each format, translate the data and post
    // it to the Clipboard.
    DataTransferer dataTransferer = DataTransferer.getInstance();
    long[] formatArray = dataTransferer.getFormatsForTransferableAsArray(contents, flavorMap);
    declareTypes(formatArray, this);

    Map<Long, DataFlavor> formatMap = dataTransferer.getFormatsForTransferable(contents, flavorMap);
    for (Map.Entry<Long, DataFlavor> entry : formatMap.entrySet()) {
        long format = entry.getKey();
        DataFlavor flavor = entry.getValue();

        try {
            byte[] bytes = DataTransferer.getInstance().translateTransferable(contents, flavor, format);
            setData(bytes, format);
        } catch (IOException e) {
            // Fix 4696186: don't print exception if data with
            // javaJVMLocalObjectMimeType failed to serialize.
            // May remove this if-check when 5078787 is fixed.
            if (!(flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType) &&
                    e instanceof NotSerializableException)) {
                e.printStackTrace();
            }
        }
    }

    notifyChanged();
}
项目:openjdk-jdk10    文件:RMIConnector.java   
private void rethrowDeserializationException(IOException ioe)
        throws ClassNotFoundException, IOException {
    // specially treating for an UnmarshalException
    if (ioe instanceof UnmarshalException) {
        NotSerializableException nse = new NotSerializableException();
        nse.initCause(ioe);
        throw nse; // the fix of 6937053 made ClientNotifForwarder.fetchNotifs
                   // fetch one by one with UnmarshalException
    }

    // Not serialization problem, return.
}
项目:monarch    文件:DirectChannel.java   
/**
 * Method send.
 * 
 * @param mgr - the membership manager
 * @param destinations - the address(es) to send the message to.
 * @param msg - the message to send
 * @param ackWaitThreshold
 * @param ackSAThreshold severe alert threshold
 * @return number of bytes sent
 * @throws ConnectExceptions if message could not be send to one or more of the
 *         <code>destinations</code>
 * @throws NotSerializableException If the content cannot be serialized
 * @throws ConnectionException if the conduit has stopped
 */
public int send(MembershipManager mgr, InternalDistributedMember[] destinations,
    DistributionMessage msg, long ackWaitThreshold, long ackSAThreshold)
    throws ConnectExceptions, NotSerializableException {

  if (disconnected) {
    if (logger.isDebugEnabled()) {
      logger.debug("Returning from DirectChannel send because channel is disconnected: {}", msg);
    }
    return 0;
  }
  if (destinations == null) {
    if (logger.isDebugEnabled()) {
      logger.debug("Returning from DirectChannel send because null set passed in: {}", msg);
    }
    return 0;
  }
  if (destinations.length == 0) {
    if (logger.isDebugEnabled()) {
      logger.debug("Returning from DirectChannel send because empty destinations passed in {}",
          msg);
    }
    return 0;
  }

  msg.setSender(localAddr);
  if (destinations.length == 1) {
    return sendToOne(mgr, destinations, msg, ackWaitThreshold, ackSAThreshold);
  } else {
    return sendToMany(mgr, destinations, msg, ackWaitThreshold, ackSAThreshold);
  }
}
项目:monarch    文件:DistributionChannel.java   
/**
 * @return list of recipients who did not receive the message because they left the view (null if
 *         all received it or it was sent to {@link DistributionMessage#ALL_RECIPIENTS}).
 * @throws NotSerializableException If content cannot be serialized
 */
public Set send(InternalDistributedMember[] destinations, DistributionMessage content,
    DistributionManager dm, DistributionStats stats) throws NotSerializableException {
  if (membershipManager == null) {
    logger.warn(LocalizedMessage.create(
        LocalizedStrings.DistributionChannel_ATTEMPTING_A_SEND_TO_A_DISCONNECTED_DISTRIBUTIONMANAGER));
    if (destinations.length == 1 && destinations[0] == DistributionMessage.ALL_RECIPIENTS)
      return null;
    HashSet result = new HashSet();
    for (int i = 0; i < destinations.length; i++)
      result.add(destinations[i]);
    return result;
  }
  return membershipManager.send(destinations, content, stats);
}
项目:monarch    文件:GemFireSecurityExceptionTest.java   
private void assertPreConditions() {
  catchException(this).clone(this.nonSerializableNamingException);
  assertThat((Throwable) caughtException()).isNotNull();
  assertThat((Throwable) caughtException().getCause())
      .isInstanceOf(NotSerializableException.class);

  catchException(this).clone(this.serializableNamingException);
  assertThat((Throwable) caughtException()).isNull();

  assertThat(this.nonSerializableResolvedObj).isNotInstanceOf(Serializable.class);

  catchException(this).clone(this.serializableResolvedObj);
  assertThat((Throwable) caughtException()).isNull();
}
项目:monarch    文件:BlobHelperTest.java   
@Test
public void serializeUnserializableToStreamThrowsNotSerializableException() throws Exception {
  HeapDataOutputStream hdos = createHeapDataOutputStream();

  assertThatThrownBy(() -> serializeTo(new Object(), hdos))
      .isExactlyInstanceOf(NotSerializableException.class).hasMessage(Object.class.getName());
}
项目:jdk8u-jdk    文件:CertPath.java   
/**
 * Replaces the {@code CertPath} to be serialized with a
 * {@code CertPathRep} object.
 *
 * @return the {@code CertPathRep} to be serialized
 *
 * @throws ObjectStreamException if a {@code CertPathRep} object
 * representing this certification path could not be created
 */
protected Object writeReplace() throws ObjectStreamException {
    try {
        return new CertPathRep(type, getEncoded());
    } catch (CertificateException ce) {
        NotSerializableException nse =
            new NotSerializableException
                ("java.security.cert.CertPath: " + type);
        nse.initCause(ce);
        throw nse;
    }
}
项目:openjdk-jdk10    文件:ClientNotifForwarder.java   
private NotificationResult fetchNotifs() {
    try {
        NotificationResult nr = ClientNotifForwarder.this.
            fetchNotifs(clientSequenceNumber,maxNotifications,
                        timeout);

        if (logger.traceOn()) {
            logger.trace("NotifFetcher-run",
                         "Got notifications from the server: "+nr);
        }

        return nr;
    } catch (ClassNotFoundException | NotSerializableException e) {
        logger.trace("NotifFetcher.fetchNotifs", e);
        return fetchOneNotif();
    } catch (IOException ioe) {
        if (!shouldStop()) {
            logger.error("NotifFetcher-run",
                         "Failed to fetch notification, " +
                         "stopping thread. Error is: " + ioe, ioe);
            logger.debug("NotifFetcher-run",ioe);
        }

        // no more fetching
        return null;
    }
}
项目:jdk8u-jdk    文件:ClientNotifForwarder.java   
private NotificationResult fetchNotifs() {
    try {
        NotificationResult nr = ClientNotifForwarder.this.
            fetchNotifs(clientSequenceNumber,maxNotifications,
                        timeout);

        if (logger.traceOn()) {
            logger.trace("NotifFetcher-run",
                         "Got notifications from the server: "+nr);
        }

        return nr;
    } catch (ClassNotFoundException | NotSerializableException | UnmarshalException e) {
        logger.trace("NotifFetcher.fetchNotifs", e);
        return fetchOneNotif();
    } catch (IOException ioe) {
        if (!shouldStop()) {
            logger.error("NotifFetcher-run",
                         "Failed to fetch notification, " +
                         "stopping thread. Error is: " + ioe, ioe);
            logger.debug("NotifFetcher-run",ioe);
        }

        // no more fetching
        return null;
    }
}
项目:incubator-netbeans    文件:WritableXMLFileSystem.java   
private void writeObject(ObjectOutputStream out) throws IOException {
    throw new NotSerializableException("WritableXMLFileSystem is not persistent"); // NOI18N
}
项目:openjdk-jdk10    文件:UnwarrantedOptimismException.java   
private void writeObject(final ObjectOutputStream out) throws NotSerializableException {
    throw new NotSerializableException(getClass().getName());
}
项目:incubator-netbeans    文件:SystemFileSystem.java   
private Object writeReplace() throws ObjectStreamException {
    new NotSerializableException("WARNING - SystemFileSystem is not designed to be serialized").printStackTrace(); // NOI18N
    return new SingletonSerializer();
}
项目:JDigitalSimulator    文件:Simulation.java   
private void writeObject(ObjectOutputStream out) throws IOException {
    throw new NotSerializableException("Only the model of a simulation is serializable (properties and data).");
}
项目:JDigitalSimulator    文件:Simulation.java   
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    throw new NotSerializableException("You may only deserialize a the model of a simulation (properties and data) to pass it to the prepared constuctor.");
}
项目:tomcat7    文件:DeltaSession.java   
private void readObject(ObjectInput stream) throws ClassNotFoundException, IOException {

        // Deserialize the scalar instance variables (except Manager)
        authType = null; // Transient only
        creationTime = ( (Long) stream.readObject()).longValue();
        lastAccessedTime = ( (Long) stream.readObject()).longValue();
        maxInactiveInterval = ( (Integer) stream.readObject()).intValue();
        isNew = ( (Boolean) stream.readObject()).booleanValue();
        isValid = ( (Boolean) stream.readObject()).booleanValue();
        thisAccessedTime = ( (Long) stream.readObject()).longValue();
        version = ( (Long) stream.readObject()).longValue();
        boolean hasPrincipal = stream.readBoolean();
        principal = null;
        if (hasPrincipal) {
            principal = SerializablePrincipal.readPrincipal(stream);
        }

        //        setId((String) stream.readObject());
        id = (String) stream.readObject();
        if (log.isDebugEnabled()) log.debug(sm.getString("deltaSession.readSession", id));

        // Deserialize the attribute count and attribute values
        if (attributes == null) attributes = new ConcurrentHashMap<String, Object>();
        int n = ( (Integer) stream.readObject()).intValue();
        boolean isValidSave = isValid;
        isValid = true;
        for (int i = 0; i < n; i++) {
            String name = (String) stream.readObject();
            final Object value;
            try {
                value = stream.readObject();
            } catch (WriteAbortedException wae) {
                if (wae.getCause() instanceof NotSerializableException) {
                    // Skip non serializable attributes
                    continue;
                }
                throw wae;
            }
            // Handle the case where the filter configuration was changed while
            // the web application was stopped.
            if (exclude(name, value)) {
                continue;
            }
            attributes.put(name, value);
        }
        isValid = isValidSave;

        // Session listeners
        n = ((Integer) stream.readObject()).intValue();
        if (listeners == null || n > 0) {
            listeners = new ArrayList<SessionListener>();
        }
        for (int i = 0; i < n; i++) {
            SessionListener listener = (SessionListener) stream.readObject();
            listeners.add(listener);
        }

        if (notes == null) {
            notes = new Hashtable<String,Object>();
        }
        activate();
    }
项目:tomcat7    文件:StandardSession.java   
/**
 * Read a serialized version of this session object from the specified
 * object input stream.
 * <p>
 * <b>IMPLEMENTATION NOTE</b>:  The reference to the owning Manager
 * is not restored by this method, and must be set explicitly.
 *
 * @param stream The input stream to read from
 *
 * @exception ClassNotFoundException if an unknown class is specified
 * @exception IOException if an input/output error occurs
 */
protected void readObject(ObjectInputStream stream)
    throws ClassNotFoundException, IOException {

    // Deserialize the scalar instance variables (except Manager)
    authType = null;        // Transient only
    creationTime = ((Long) stream.readObject()).longValue();
    lastAccessedTime = ((Long) stream.readObject()).longValue();
    maxInactiveInterval = ((Integer) stream.readObject()).intValue();
    isNew = ((Boolean) stream.readObject()).booleanValue();
    isValid = ((Boolean) stream.readObject()).booleanValue();
    thisAccessedTime = ((Long) stream.readObject()).longValue();
    principal = null;        // Transient only
    //        setId((String) stream.readObject());
    id = (String) stream.readObject();
    if (manager.getContainer().getLogger().isDebugEnabled())
        manager.getContainer().getLogger().debug
            ("readObject() loading session " + id);

    // Deserialize the attribute count and attribute values
    if (attributes == null)
        attributes = new ConcurrentHashMap<String, Object>();
    int n = ((Integer) stream.readObject()).intValue();
    boolean isValidSave = isValid;
    isValid = true;
    for (int i = 0; i < n; i++) {
        String name = (String) stream.readObject();
        final Object value;
        try {
            value = stream.readObject();
        } catch (WriteAbortedException wae) {
            if (wae.getCause() instanceof NotSerializableException) {
                String msg = sm.getString("standardSession.notDeserializable", name, id);
                if (manager.getContainer().getLogger().isDebugEnabled()) {
                    manager.getContainer().getLogger().debug(msg, wae);
                } else {
                    manager.getContainer().getLogger().warn(msg);
                }
                // Skip non serializable attributes
                continue;
            }
            throw wae;
        }
        if (manager.getContainer().getLogger().isDebugEnabled())
            manager.getContainer().getLogger().debug("  loading attribute '" + name +
                "' with value '" + value + "'");
        // Handle the case where the filter configuration was changed while
        // the web application was stopped.
        if (exclude(name, value)) {
            continue;
        }
        attributes.put(name, value);
    }
    isValid = isValidSave;

    if (listeners == null) {
        listeners = new ArrayList<SessionListener>();
    }

    if (notes == null) {
        notes = new Hashtable<String, Object>();
    }
}