Skip to content

Commit

Permalink
re apiman#349 Catch error in ActionResourceImpl when republishing
Browse files Browse the repository at this point in the history
  • Loading branch information
kahboom committed Feb 18, 2016
1 parent 0f8e678 commit 1225416
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
}
Expand Down

0 comments on commit 1225416

Please sign in to comment.