/* * There are several cases this test fails: * * 1. The random selected port is used by another process. No good way to * prevent this happening, coz krb5.conf must be written before KDC starts. * There are two different outcomes: * * a. Cannot start the KDC. A BindException thrown. * b. When trying to access a non-existing KDC, a response is received! * Most likely a Asn1Exception thrown * * 2. Even if a KDC is started, and more than 20 seconds pass by, a timeout * can still happens for the first UDP request. In fact, the KDC did not * received it at all. This happens on almost all platforms, especially * solaris-i586 and solaris-x64. * * To avoid them: * * 1. Catch those exceptions and ignore * * 2. a. Make the timeout longer? useless * b. Read the output carefully, if there is a timeout, it's OK. * Just make sure the retries times and KDCs are correct. * This is tough. * c. Feed the KDC a UDP packet first. The current "solution". */ public static void go(String... expected) throws Exception { try { go0(expected); } catch (BindException be) { System.out.println("The random port is used by another process"); } catch (LoginException le) { Throwable cause = le.getCause(); if (cause instanceof Asn1Exception) { System.out.println("Bad packet possibly from another process"); return; } throw le; } }