Search in sources :

Example 1 with TransportTimeoutException

use of com.sun.jdi.connect.TransportTimeoutException in project jdk8u_jdk by JetBrains.

the class AcceptTimeout method main.

public static void main(String[] args) throws Exception {
    List<ListeningConnector> connectors = Bootstrap.virtualMachineManager().listeningConnectors();
    for (ListeningConnector lc : connectors) {
        Map<String, Connector.Argument> cargs = lc.defaultArguments();
        Connector.IntegerArgument timeout = (Connector.IntegerArgument) cargs.get("timeout");
        /*
             * If the Connector has a argument named "timeout" then we set the timeout to 1 second
             * and start it listening on its default address. It should throw TranpsortTimeoutException.
             */
        if (timeout != null) {
            System.out.println("Testing " + lc.name());
            timeout.setValue(1000);
            System.out.println("Listening on: " + lc.startListening(cargs));
            try {
                lc.accept(cargs);
                throw new RuntimeException("Connection accepted from some debuggee - unexpected!");
            } catch (TransportTimeoutException e) {
                System.out.println("Timed out as expected.\n");
            }
            lc.stopListening(cargs);
        }
    }
}
Also used : ListeningConnector(com.sun.jdi.connect.ListeningConnector) Connector(com.sun.jdi.connect.Connector) TransportTimeoutException(com.sun.jdi.connect.TransportTimeoutException) ListeningConnector(com.sun.jdi.connect.ListeningConnector)

Aggregations

Connector (com.sun.jdi.connect.Connector)1 ListeningConnector (com.sun.jdi.connect.ListeningConnector)1 TransportTimeoutException (com.sun.jdi.connect.TransportTimeoutException)1