@SuppressWarnings("unchecked")
final Callable<Boolean> timeLimitedConnection = timeLimiter.newProxy(
new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return connection.connect();
}
}, Callable.class,
connectionTimeout, TimeUnit.MILLISECONDS);
try {
final Boolean connected = timeLimitedConnection.call();