Search in sources :

Example 1 with RPCRequest

use of hudson.remoting.RemoteInvocationHandler.RPCRequest in project hudson-2.x by hudson.

the class TrafficAnalyzer method main.

public static void main(String[] args) throws Exception {
    File f = new File("/home/kohsuke/ws/hudson/investigations/javafx-windows-hang/out.log");
    DataInputStream fin = new DataInputStream(new FileInputStream(f));
    // skip preamble
    fin.readFully(new byte[4]);
    ObjectInputStream ois = new ObjectInputStream(fin);
    for (int n = 0; ; n++) {
        Command o = (Command) ois.readObject();
        System.out.println("#" + n + " : " + o);
        if (o instanceof RPCRequest) {
            RPCRequest request = (RPCRequest) o;
            System.out.print("  (");
            boolean first = true;
            for (Object argument : request.getArguments()) {
                if (first)
                    first = false;
                else
                    System.out.print(",");
                System.out.print(argument);
            }
            System.out.println(")");
        }
        if (o.createdAt != null)
            o.createdAt.printStackTrace(System.out);
    }
}
Also used : RPCRequest(hudson.remoting.RemoteInvocationHandler.RPCRequest) DataInputStream(java.io.DataInputStream) File(java.io.File) FileInputStream(java.io.FileInputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with RPCRequest

use of hudson.remoting.RemoteInvocationHandler.RPCRequest in project hudson-2.x by hudson.

the class UserResponse method perform.

protected UserResponse<RSP, EXC> perform(Channel channel) throws EXC {
    try {
        ClassLoader cl = channel.importedClassLoaders.get(classLoaderProxy);
        RSP r = null;
        Channel oldc = Channel.setCurrent(channel);
        try {
            Object o;
            try {
                o = deserialize(channel, request, cl);
            } catch (ClassNotFoundException e) {
                throw new ClassNotFoundException("Failed to deserialize the Callable object. Perhaps you needed to implement DelegatingCallable?", e);
            }
            Callable<RSP, EXC> callable = (Callable<RSP, EXC>) o;
            if (channel.isRestricted && !(callable instanceof RPCRequest))
                // OTOH, we need to allow RPCRequest so that method invocations on exported objects will go through.
                throw new SecurityException("Execution of " + callable.toString() + " is prohibited because the channel is restricted");
            ClassLoader old = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(cl);
            // execute the service
            try {
                r = callable.call();
            } finally {
                Thread.currentThread().setContextClassLoader(old);
            }
        } finally {
            Channel.setCurrent(oldc);
        }
        return new UserResponse<RSP, EXC>(serialize(r, channel), false);
    } catch (Throwable e) {
        // propagate this to the calling process
        try {
            byte[] response;
            try {
                response = _serialize(e, channel);
            } catch (NotSerializableException x) {
                // perhaps the thrown runtime exception is of type we can't handle
                response = serialize(new ProxyException(e), channel);
            }
            return new UserResponse<RSP, EXC>(response, true);
        } catch (IOException x) {
            // throw it as a lower-level exception
            throw (EXC) x;
        }
    }
}
Also used : IOException(java.io.IOException) NotSerializableException(java.io.NotSerializableException) RPCRequest(hudson.remoting.RemoteInvocationHandler.RPCRequest) IClassLoader(hudson.remoting.RemoteClassLoader.IClassLoader)

Aggregations

RPCRequest (hudson.remoting.RemoteInvocationHandler.RPCRequest)2 IClassLoader (hudson.remoting.RemoteClassLoader.IClassLoader)1 DataInputStream (java.io.DataInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 NotSerializableException (java.io.NotSerializableException)1 ObjectInputStream (java.io.ObjectInputStream)1