diff --git a/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java b/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java index 28ffbaa3c8..9ac62f6d5b 100644 --- a/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java +++ b/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/ActionResourceImpl.java @@ -404,7 +404,14 @@ private void registerClient(ActionBean action) throws ActionException { GatewayBean gbean = gateways.next(); if (!links.containsKey(gbean.getId())) { IGatewayLink gatewayLink = createGatewayLink(gbean.getId()); - gatewayLink.unregisterClient(client); + + try { + gatewayLink.unregisterClient(client); + } catch (Exception e) { + // We need to catch the error, but ignore it, + // in the event that the gateway is invalid. + } + gatewayLink.close(); } } diff --git a/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/mappers/RestExceptionMapper.java b/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/mappers/RestExceptionMapper.java index 3ed09df6dc..9a096abcd0 100644 --- a/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/mappers/RestExceptionMapper.java +++ b/manager/api/rest-impl/src/main/java/io/apiman/manager/api/rest/impl/mappers/RestExceptionMapper.java @@ -55,7 +55,6 @@ public RestExceptionMapper() { */ @Override public Response toResponse(AbstractRestException data) { - String origin = securityContext.getRequestHeader("Origin"); //$NON-NLS-1$ ErrorBean error = new ErrorBean(); error.setType(data.getClass().getSimpleName()); error.setErrorCode(data.getErrorCode()); @@ -64,11 +63,6 @@ public Response toResponse(AbstractRestException data) { error.setStacktrace(getStackTrace(data)); ResponseBuilder builder = Response.status(data.getHttpCode()).header("X-Apiman-Error", "true"); //$NON-NLS-1$ //$NON-NLS-2$ // If CORS is being used, make sure to add X-Apiman-Error to the exposed headers - if (origin != null) { - builder = builder.header("Access-Control-Expose-Headers", "X-Apiman-Error") //$NON-NLS-1$ //$NON-NLS-2$ - .header("Access-Control-Allow-Origin", origin) //$NON-NLS-1$ - .header("Access-Control-Allow-Credentials", "true"); //$NON-NLS-1$ //$NON-NLS-2$ - } builder.type(MediaType.APPLICATION_JSON_TYPE); return builder.entity(error).build(); }