fix(gateway) Fix two errors printing in Servlet.
MODIFY
gateway/engine/beans/src/main/java/io/apiman/gateway/engine/beans/exceptions/RequestAbortedException.java
gateway/engine/beans/src/main/java/io/apiman/gateway/engine/beans/exceptions/RequestAbortedException.java
@@ -33,4 +33,12 @@ public class RequestAbortedException extends AbstractEngineException {
public RequestAbortedException() {
}
+ public RequestAbortedException(Throwable cause) {
+ super(cause);
+ }
+
+ public RequestAbortedException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
}

MODIFY
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/ApiRequestExecutorImpl.java
@@ -301,7 +301,7 @@ public class ApiRequestExecutorImpl implements IApiRequestExecutor {
connectorStream.end();
}
} catch (Exception e) {
- connectorStream.abort();
+ connectorStream.abort(e);
throw new RuntimeException(e);
}
}
@@ -427,9 +427,9 @@ public class ApiRequestExecutorImpl implements IApiRequestExecutor {
private boolean done = false;
@Override
- public void abort() {
+ public void abort(Throwable t) {
done = true;
- payloadResultHandler.handle(AsyncResultImpl.create(new Exception("Inbound request stream aborted."))); //$NON-NLS-1$
+ payloadResultHandler.handle(AsyncResultImpl.create(new RuntimeException("Inbound request stream aborted.", t))); //$NON-NLS-1$
}
@Override
@@ -727,14 +727,14 @@ public class ApiRequestExecutorImpl implements IApiRequestExecutor {
* @see io.apiman.gateway.engine.io.IAbortable#abort()
*/
@Override
- public void abort() {
+ public void abort(Throwable t) {
// If this is called, it means that something went wrong on the inbound
// side of things - so we need to make sure we abort and cleanup the
// api connector resources. We'll also call handle() on the result
// handler so that the caller knows something went wrong.
streamFinished = true;
- apiConnection.abort();
- resultHandler.handle(AsyncResultImpl.<IEngineResult>create(new RequestAbortedException()));
+ apiConnection.abort(t);
+ resultHandler.handle(AsyncResultImpl.<IEngineResult>create(new RequestAbortedException(t)));
}

MODIFY
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/EngineResultImpl.java
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/EngineResultImpl.java
@@ -116,8 +116,8 @@ public class EngineResultImpl extends AbstractStream<ApiResponse> implements IEn
* @see io.apiman.gateway.engine.io.IAbortable#abort()
*/
@Override
- public void abort() {
- connectorResponseStream.abort();
+ public void abort(Throwable t) {
+ connectorResponseStream.abort(t);
}
/**

MODIFY
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/InMemoryCacheStoreComponent.java
gateway/engine/core/src/main/java/io/apiman/gateway/engine/impl/InMemoryCacheStoreComponent.java
@@ -94,7 +94,7 @@ public class InMemoryCacheStoreComponent implements ICacheStoreComponent {
return new ISignalWriteStream() {
private boolean finished = false;
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
}
@Override
@@ -226,7 +226,7 @@ public class InMemoryCacheStoreComponent implements ICacheStoreComponent {
return finished;
}
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
}
@Override

MODIFY
gateway/engine/core/src/main/java/io/apiman/gateway/engine/io/IAbortable.java
gateway/engine/core/src/main/java/io/apiman/gateway/engine/io/IAbortable.java
@@ -23,6 +23,14 @@ package io.apiman.gateway.engine.io;
public interface IAbortable {
/**
* Signal abort.
+ * @param t the throwable
*/
- void abort();
+ void abort(Throwable t);
+
+ /**
+ * Signal abort.
+ */
+ default void abort() {
+ abort(null);
+ }
}

MODIFY
gateway/engine/core/src/main/java/io/apiman/gateway/engine/policy/Chain.java
gateway/engine/core/src/main/java/io/apiman/gateway/engine/policy/Chain.java
@@ -226,7 +226,7 @@ public abstract class Chain<H> extends AbstractStream<H> implements IAbortable,
*/
@Override
public void doFailure(PolicyFailure failure) {
- abort();
+ abort(null);
policyFailureHandler.handle(failure);
}
@@ -245,7 +245,7 @@ public abstract class Chain<H> extends AbstractStream<H> implements IAbortable,
*/
@Override
public void throwError(Throwable error) {
- abort();
+ abort(error);
policyErrorHandler.handle(error);
}
@@ -253,7 +253,7 @@ public abstract class Chain<H> extends AbstractStream<H> implements IAbortable,
* Send abort signal to all policies.
*/
@Override
- public void abort() {
+ public void abort(Throwable t) {
// for (IPolicy policy : policies) {
// policy.abort();
// }

MODIFY
gateway/engine/core/src/test/java/io/apiman/gateway/engine/impl/DefaultEngineFactoryTest.java
gateway/engine/core/src/test/java/io/apiman/gateway/engine/impl/DefaultEngineFactoryTest.java
@@ -157,7 +157,7 @@ public class DefaultEngineFactoryTest {
}
@Override
- public void abort() {
+ public void abort(Throwable t) {
}
};

MODIFY
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESCacheStoreComponent.java
gateway/engine/es/src/main/java/io/apiman/gateway/engine/es/ESCacheStoreComponent.java
@@ -96,7 +96,7 @@ public class ESCacheStoreComponent extends AbstractESComponent implements ICache
boolean finished = false;
boolean aborted = false;
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
aborted = false;
}
@@ -200,7 +200,7 @@ public class ESCacheStoreComponent extends AbstractESComponent implements ICache
return finished;
}
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
aborted = true;
}

MODIFY
gateway/engine/ispn/src/main/java/io/apiman/gateway/engine/ispn/InfinispanCacheStoreComponent.java
gateway/engine/ispn/src/main/java/io/apiman/gateway/engine/ispn/InfinispanCacheStoreComponent.java
@@ -86,7 +86,7 @@ public class InfinispanCacheStoreComponent extends AbstractInfinispanComponent i
private boolean finished = false;
private boolean aborted = false;
@Override
- public void abort() {
+ public void abort(Throwable t) {
aborted = true;
finished = false;
}
@@ -178,7 +178,7 @@ public class InfinispanCacheStoreComponent extends AbstractInfinispanComponent i
return finished;
}
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
}
@Override

MODIFY
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/caching/CacheConnectorInterceptor.java
gateway/engine/policies/src/main/java/io/apiman/gateway/engine/policies/caching/CacheConnectorInterceptor.java
@@ -100,11 +100,11 @@ public class CacheConnectorInterceptor implements IConnectorInterceptor, IApiCon
* @see io.apiman.gateway.engine.io.IAbortable#abort()
*/
@Override
- public void abort() {
+ public void abort(Throwable t) {
if (!finished) {
finished = true;
connected = false;
- cacheEntry.abort();
+ cacheEntry.abort(t);
}
}

MODIFY
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/GatewayServlet.java
@@ -143,7 +143,7 @@ public abstract class GatewayServlet extends HttpServlet {
// this would mean we couldn't get the output stream from the response, so we
// need to abort the engine result (which will let the back-end connection
// close down).
- engineResult.abort();
+ engineResult.abort(e);
latch.countDown();
throw new RuntimeException(e);
}
@@ -170,8 +170,7 @@ public abstract class GatewayServlet extends HttpServlet {
}
connectorStream.end();
} catch (Throwable e) {
- connectorStream.abort();
- throw new RuntimeException(e);
+ connectorStream.abort(e);
}
}
});

MODIFY
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/HttpApiConnection.java
gateway/platforms/servlet/src/main/java/io/apiman/gateway/platforms/servlet/connectors/HttpApiConnection.java
@@ -301,7 +301,7 @@ public class HttpApiConnection implements IApiConnection, IApiConnectionResponse
* @see io.apiman.gateway.engine.io.IAbortable#abort()
*/
@Override
- public void abort() {
+ public void abort(Throwable t) {
try {
if (!connected) {
throw new IOException("Not connected."); //$NON-NLS-1$
@@ -398,7 +398,7 @@ public class HttpApiConnection implements IApiConnection, IApiConnectionResponse
// the originating client - and we're in the process of sending the body data. So
// I guess the only thing to do is abort() the connection and cross our fingers.
if (connected) {
- abort();
+ abort(e);
}
throw new RuntimeException(e);
}

MODIFY
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/connector/HttpConnector.java
gateway/platforms/vertx3/vertx3/src/main/java/io/apiman/gateway/platforms/vertx3/connector/HttpConnector.java
@@ -223,7 +223,7 @@ class HttpConnector implements IApiConnectionResponse, IApiConnection {
}
@Override
- public void abort() {
+ public void abort(Throwable t) {
bodyHandler(null);
if(clientRequest != null) {

MODIFY
test/policies/src/main/java/io/apiman/test/policies/PolicyTesterApiConnection.java
test/policies/src/main/java/io/apiman/test/policies/PolicyTesterApiConnection.java
@@ -110,7 +110,7 @@ public class PolicyTesterApiConnection implements IApiConnection {
* @see io.apiman.gateway.engine.io.IAbortable#abort()
*/
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
}

MODIFY
test/policies/src/main/java/io/apiman/test/policies/PolicyTesterApiConnectionResponse.java
test/policies/src/main/java/io/apiman/test/policies/PolicyTesterApiConnectionResponse.java
@@ -89,7 +89,7 @@ public class PolicyTesterApiConnectionResponse implements IApiConnectionResponse
* @see io.apiman.gateway.engine.io.IAbortable#abort()
*/
@Override
- public void abort() {
+ public void abort(Throwable t) {
finished = true;
}

fix(gateway) Fix two errors printing in Servlet.