chibenwa commented on code in PR #298:
URL:
https://github.com/apache/apisix-java-plugin-runner/pull/298#discussion_r1928346022
##########
runner-core/src/main/java/org/apache/apisix/plugin/runner/handler/ExceptionCaughtHandler.java:
##########
@@ -21,15 +21,33 @@
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import org.apache.apisix.plugin.runner.A6ErrResponse;
+import org.apache.apisix.plugin.runner.exception.ExceptionCaught;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
+import java.util.List;
+
public class ExceptionCaughtHandler extends ChannelInboundHandlerAdapter {
private final Logger logger =
LoggerFactory.getLogger(ExceptionCaughtHandler.class);
+ List<ExceptionCaught> exceptionCaughtList = new
ArrayList<ExceptionCaught>();
+
+ public ExceptionCaughtHandler() {
+
+ }
+
+ public ExceptionCaughtHandler(List<ExceptionCaught> exceptionCaughtList) {
+ this.exceptionCaughtList = exceptionCaughtList;
+ }
+
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
throws Exception {
logger.error("handle request error: ", cause);
+ if (!exceptionCaughtList.isEmpty()) {
+ exceptionCaughtList.get(0).exceptionCaught(ctx, cause);
Review Comment:
Why a list if we always use the first one?
##########
runner-core/src/main/java/org/apache/apisix/plugin/runner/handler/RpcCallHandler.java:
##########
@@ -311,8 +309,7 @@ private void preReadReq() {
}
private void errorHandle(ChannelHandlerContext ctx, int code) {
- A6ErrResponse errResponse = new A6ErrResponse(code);
- ctx.writeAndFlush(errResponse);
+ throw new ApisixException(code, Code.name(code));
Review Comment:
Could you please provide detailed explanation and impact assesments on
moving exception handling out of the Netty stack?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]