java.rmi.UnmarshalException Java Examples

The following examples show how to use java.rmi.UnmarshalException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivationID.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #2
Source File: ActivationID.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #3
Source File: ClientMgr.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 *  Tells the given client vm to exit.  Optionally asks it to disconnect
 *  from GemFire before exiting.
 */
private static void stopClient( ClientVmRecord vm,
                                boolean closeConnection,
		  boolean runShutdownHook) {
  log().info( "Issuing stop request to " + vm.toInfoString() );
  synchronized( vm ) {
    if ( vm.getPid() == ClientVmRecord.NO_PID ) {
      log().info( vm.toInfoString() + " is already stopped" );
      return;
    }
    ClientRecord cr = vm.getRepresentativeClient();
    try {
      cr.getTestModule().shutDownVM( closeConnection, runShutdownHook );
    } catch( UnmarshalException ignore ) {
      // vm is shutting down, don't expect clean reply
    } catch( RemoteException e ) {
      String reason = "Unable to reach client " + cr + " in " + vm;
      throw new HydraRuntimeException( reason, e );
    }
  }
  log().info( "Issued stop request to " + vm.toInfoString() );
}
 
Example #4
Source File: RMIConnector.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #5
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
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.
}
 
Example #6
Source File: ActivationID.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #7
Source File: ClientMgr.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
private static void runClientShutdownHook( ClientVmRecord vm ) {
  log().info( "Running client shutdown hook in " + vm.toInfoString() );
  ClientRecord cr = null;
  synchronized( vm ) {
    if ( vm.getPid() == ClientVmRecord.NO_PID ) {
      log().info( vm.toInfoString() + " is stopped: can't run client shutdown hook" );
      return;
    }
    cr = vm.getRepresentativeClient();
  }
  // must run hook outside vm synchronization since it is a fully synchronous
  // RMI call that could hang, deadlocking master attempt to do stack dumps,
  // but all is well since the cr test module is never unset and we already
  // handle an intervening shutdown
  try {
    cr.getTestModule().runShutdownHook( );
  } catch( UnmarshalException ignore ) {
    // vm is shutting down, don't expect clean reply
  } catch( RemoteException e ) {
    String reason = "Unable to reach client " + cr + " in " + vm;
    log().severe(reason, e);
  }
  log().info( "Ran client shutdown hook in " + vm.toInfoString() );
}
 
Example #8
Source File: ClientMgr.java    From gemfirexd-oss with Apache License 2.0 6 votes vote down vote up
/**
 *  Tells the given client vm to exit.  Optionally asks it to disconnect
 *  from GemFire before exiting.
 */
private static void stopClient( ClientVmRecord vm,
                                boolean closeConnection,
		  boolean runShutdownHook) {
  log().info( "Issuing stop request to " + vm.toInfoString() );
  synchronized( vm ) {
    if ( vm.getPid() == ClientVmRecord.NO_PID ) {
      log().info( vm.toInfoString() + " is already stopped" );
      return;
    }
    ClientRecord cr = vm.getRepresentativeClient();
    try {
      cr.getTestModule().shutDownVM( closeConnection, runShutdownHook );
    } catch( UnmarshalException ignore ) {
      // vm is shutting down, don't expect clean reply
    } catch( RemoteException e ) {
      String reason = "Unable to reach client " + cr + " in " + vm;
      throw new HydraRuntimeException( reason, e );
    }
  }
  log().info( "Issued stop request to " + vm.toInfoString() );
}
 
Example #9
Source File: RMIConnector.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #10
Source File: RMIConnector.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #11
Source File: RMIConnector.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
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.
}
 
Example #12
Source File: RMIConnector.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #13
Source File: ActivationID.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #14
Source File: RMIConnector.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #15
Source File: ActivationID.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #16
Source File: RMIConnector.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #17
Source File: RMIConnector.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #18
Source File: RMIConnector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #19
Source File: FilterUSRTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
Example #20
Source File: ActivationID.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #21
Source File: FilterUSRTest.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
Example #22
Source File: RMIConnector.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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.
}
 
Example #23
Source File: ActivationID.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Activate the object for this id.
 *
 * @param force if true, forces the activator to contact the group
 * when activating the object (instead of returning a cached reference);
 * if false, returning a cached value is acceptable.
 * @return the reference to the active remote object
 * @exception ActivationException if activation fails
 * @exception UnknownObjectException if the object is unknown
 * @exception RemoteException if remote call fails
 * @since 1.2
 */
public Remote activate(boolean force)
    throws ActivationException, UnknownObjectException, RemoteException
{
    try {
        MarshalledObject<? extends Remote> mobj =
            activator.activate(this, force);
        return AccessController.doPrivileged(
            new PrivilegedExceptionAction<Remote>() {
                public Remote run() throws IOException, ClassNotFoundException {
                    return mobj.get();
                }
            }, NOPERMS_ACC);
    } catch (PrivilegedActionException pae) {
        Exception ex = pae.getException();
        if (ex instanceof RemoteException) {
            throw (RemoteException) ex;
        } else {
            throw new UnmarshalException("activation failed", ex);
        }
    }

}
 
Example #24
Source File: RMIConnector.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
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.
}
 
Example #25
Source File: FilterUSRTest.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "bindData")
public void UnicastServerRef(String name, Object obj, int expectedFilterCount) throws RemoteException {
    try {
        RemoteImpl impl = RemoteImpl.create();
        UnicastServerRef ref = new UnicastServerRef(new LiveRef(0), impl.checker);

        Echo client = (Echo) ref.exportObject(impl, null, false);

        int count = client.filterCount(obj);
        System.out.printf("count: %d, obj: %s%n", count, obj);
        Assert.assertEquals(count, expectedFilterCount, "wrong number of filter calls");
    } catch (RemoteException rex) {
        if (expectedFilterCount == -1 &&
                UnmarshalException.class.equals(rex.getCause().getClass()) &&
                InvalidClassException.class.equals(rex.getCause().getCause().getClass())) {
            return; // normal expected exception
        }
        rex.printStackTrace();
        Assert.fail("unexpected remote exception", rex);
    } catch (Exception ex) {
        Assert.fail("unexpected exception", ex);
    }
}
 
Example #26
Source File: RMIConnectionImpl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T unwrap(final MarshalledObject<?> mo,
                            final ClassLoader cl1,
                            final ClassLoader cl2,
                            final Class<T> wrappedClass)
    throws IOException {
    if (mo == null) {
        return null;
    }
    try {
        ClassLoader orderCL = AccessController.doPrivileged(
            new PrivilegedExceptionAction<ClassLoader>() {
                public ClassLoader run() throws Exception {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            new OrderClassLoaders(cl1, cl2));
                }
            }
        );
        return unwrap(mo, orderCL, wrappedClass);
    } catch (PrivilegedActionException pe) {
        Exception e = extractException(pe);
        if (e instanceof IOException) {
            throw (IOException) e;
        }
        if (e instanceof ClassNotFoundException) {
            throw new UnmarshalException(e.toString(), e);
        }
        logger.warning("unwrap", "Failed to unmarshall object: " + e);
        logger.debug("unwrap", e);
    }
    return null;
}
 
Example #27
Source File: UnicastServerRef.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handle server-side dispatch using the RMI 1.1 stub/skeleton
 * protocol, given a non-negative operation number that has
 * already been read from the call stream.
 * Exceptions are handled by the caller to be sent to the remote client.
 *
 * @param obj the target remote object for the call
 * @param call the "remote call" from which operation and
 * method arguments can be obtained.
 * @param op the operation number
 * @throws Exception if unable to marshal return result or
 * release input or output streams
 */
private void oldDispatch(Remote obj, RemoteCall call, int op)
    throws Exception
{
    long hash;              // hash for matching stub with skeleton

    // read remote call header
    ObjectInput in;
    in = call.getInputStream();
    try {
        Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
        if (clazz.isAssignableFrom(skel.getClass())) {
            ((MarshalInputStream)in).useCodebaseOnly();
        }
    } catch (ClassNotFoundException ignore) { }

    try {
        hash = in.readLong();
    } catch (Exception ioe) {
        throw new UnmarshalException("error unmarshalling call header", ioe);
    }

    // if calls are being logged, write out object id and operation
    logCall(obj, skel.getOperations()[op]);
    unmarshalCustomCallData(in);
    // dispatch to skeleton for remote object
    skel.dispatch(obj, call, op, hash);
}
 
Example #28
Source File: RMIConnectionImpl.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T unwrap(final MarshalledObject<?> mo,
                            final ClassLoader cl1,
                            final ClassLoader cl2,
                            final Class<T> wrappedClass)
    throws IOException {
    if (mo == null) {
        return null;
    }
    try {
        ClassLoader orderCL = AccessController.doPrivileged(
            new PrivilegedExceptionAction<ClassLoader>() {
                public ClassLoader run() throws Exception {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            new OrderClassLoaders(cl1, cl2));
                }
            }
        );
        return unwrap(mo, orderCL, wrappedClass);
    } catch (PrivilegedActionException pe) {
        Exception e = extractException(pe);
        if (e instanceof IOException) {
            throw (IOException) e;
        }
        if (e instanceof ClassNotFoundException) {
            throw new UnmarshalException(e.toString(), e);
        }
        logger.warning("unwrap", "Failed to unmarshall object: " + e);
        logger.debug("unwrap", e);
    }
    return null;
}
 
Example #29
Source File: RMIConnectionImpl.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T unwrap(final MarshalledObject<?> mo,
                            final ClassLoader cl1,
                            final ClassLoader cl2,
                            final Class<T> wrappedClass)
    throws IOException {
    if (mo == null) {
        return null;
    }
    try {
        ClassLoader orderCL = AccessController.doPrivileged(
            new PrivilegedExceptionAction<ClassLoader>() {
                public ClassLoader run() throws Exception {
                    return new CombinedClassLoader(Thread.currentThread().getContextClassLoader(),
                            new OrderClassLoaders(cl1, cl2));
                }
            }
        );
        return unwrap(mo, orderCL, wrappedClass);
    } catch (PrivilegedActionException pe) {
        Exception e = extractException(pe);
        if (e instanceof IOException) {
            throw (IOException) e;
        }
        if (e instanceof ClassNotFoundException) {
            throw new UnmarshalException(e.toString(), e);
        }
        logger.warning("unwrap", "Failed to unmarshall object: " + e);
        logger.debug("unwrap", e);
    }
    return null;
}
 
Example #30
Source File: ClientNotifForwarder.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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;
    }
}