try {
final Endpoint endpoint = Remoting.createEndpoint("endpoint", OptionMap.EMPTY);
endpoint.addConnectionProvider("remote", new RemoteConnectionProviderFactory(), OptionMap.create(Options.SSL_ENABLED, Boolean.FALSE));
// open a connection
final IoFuture<Connection> futureConnection = endpoint.connect(new URI(hostUrl), OptionMap.create(Options.SASL_POLICY_NOANONYMOUS, Boolean.FALSE), new AnonymousCallbackHandler());
final Connection connection = IoFutureHelper.get(futureConnection, 5L, TimeUnit.SECONDS);
try {
try {
final ClassLoader oldTccl = SecurityActions.getContextClassLoader();