Implemented PromiseWrapper's succeeded() and failed() methods.
This commit is contained in:
parent
2111775cb4
commit
571b0c74c5
|
@ -563,18 +563,12 @@ public class HttpClient extends ContainerLifeCycle
|
|||
{
|
||||
context.put(HttpClientTransport.HTTP_CONNECTION_PROMISE_CONTEXT_KEY, new Promise.Wrapper<Connection>(promise)
|
||||
{
|
||||
@Override
|
||||
public void succeeded(Connection result)
|
||||
{
|
||||
getPromise().succeeded(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
int nextIndex = index + 1;
|
||||
if (nextIndex == socketAddresses.size())
|
||||
getPromise().failed(x);
|
||||
super.failed(x);
|
||||
else
|
||||
connect(socketAddresses, nextIndex, context);
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
package org.eclipse.jetty.util;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
|
||||
/**
|
||||
|
@ -61,13 +63,25 @@ public interface Promise<C>
|
|||
}
|
||||
}
|
||||
|
||||
public static abstract class Wrapper<W> implements Promise<W>
|
||||
public static class Wrapper<W> implements Promise<W>
|
||||
{
|
||||
private final Promise<W> promise;
|
||||
|
||||
public Wrapper(Promise<W> promise)
|
||||
{
|
||||
this.promise = promise;
|
||||
this.promise = Objects.requireNonNull(promise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void succeeded(W result)
|
||||
{
|
||||
promise.succeeded(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failed(Throwable x)
|
||||
{
|
||||
promise.failed(x);
|
||||
}
|
||||
|
||||
public Promise<W> getPromise()
|
||||
|
|
Loading…
Reference in New Issue