Skip to content

Commit

Permalink
return BAD_REQUEST on transaction manager ABORT
Browse files Browse the repository at this point in the history
Error details should be available in the TM's Context
  • Loading branch information
ar committed May 16, 2018
1 parent 8849130 commit 3a4f6fc
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions modules/qrest/src/main/java/org/jpos/qrest/SendResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.http.*;
import org.jpos.rc.Result;
import org.jpos.transaction.AbortParticipant;
import org.jpos.transaction.Context;

import java.io.Serializable;
import java.util.LinkedHashMap;
import java.util.Map;

import static io.netty.buffer.Unpooled.copiedBuffer;
import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE;
Expand Down Expand Up @@ -77,6 +80,8 @@ private FullHttpResponse error (HttpResponseStatus rc) {
private FullHttpResponse getResponse (Context ctx) {
Object r = ctx.get(RESPONSE);
FullHttpResponse httpResponse;


if (r instanceof FullHttpResponse) {
httpResponse = (FullHttpResponse) r;
} else if (r instanceof Response) {
Expand All @@ -102,10 +107,13 @@ private FullHttpResponse getResponse (Context ctx) {
ctx.log(e);
httpResponse = error(HttpResponseStatus.INTERNAL_SERVER_ERROR);
}
} else
httpResponse = error(HttpResponseStatus.NOT_FOUND);

} else {
Result result = ctx.getResult();
if (result.hasFailures()) {
httpResponse = error(HttpResponseStatus.BAD_REQUEST);
} else
httpResponse = error(HttpResponseStatus.NOT_FOUND);
}
return httpResponse;
}
}

0 comments on commit 3a4f6fc

Please # to comment.