}
}
private ServerSideSession safeStart(long timeOut, IOSCapabilities cap)
throws InstrumentsFailedToStartException {
ServerSideSession session = null;
try {
// init session
session = getServer().createSession(cap);
if (session == null) {
throw new ServerIsShutingDownException(
"The server is currently shutting down and doesn't accept new tests.");
}
// start session
session.start(timeOut);
return session;
} catch (SessionNotInitializedException e) {
log.info("The server cannot run " + cap + " at the moment." + e.getMessage());
throw new SessionNotCreatedException("The server cannot run " + cap + " at the moment." + e.getMessage());
} catch (InstrumentsFailedToStartException|RecoverableCrashException e) {
log.warning("Instruments failed to start in the allocated time ( " + timeOut + "sec):" + e
.getMessage());
if (session != null) {
session.stop();
}
} catch (Exception e) {
log.warning("Error starting the session." + e.getMessage());
if (session != null) {
session.stop();
}
throw e;
} finally {
if (session != null && session.getStopCause() != null) {
log.warning("app has crashed at startup :" + session.getStopCause());
}
}
return null;
}