Open Cheol-Soon-Choi opened 1 year ago
hi @Cheol-Soon-Choi
Could you provide a minimal usable repro case? Based on the information you have provided so far, it is difficult for me to reproduce, Thanks!
my Route info
{
"uri": "/bodybody*",
"name": "test1234",
"methods": [
"GET",
"POST"
],
"plugins": {
"ext-plugin-post-resp": {
"_meta": {
"disable": false
},
"allow_degradation": false,
"conf": [
{
"name": "Test_Gateway",
"value": "{\"rejected_body2\":\"failed\",\"rejected_code2\":\"403\"}"
}
]
}
},
"upstream": {
"nodes": [
{
"host": "127.0.0.1",
"port": 8080,
"weight": 1
}
],
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"type": "roundrobin",
"scheme": "http",
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
}
},
"status": 1
}
my filter info
@Override
public void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) {
// get conf of current filter
String configStr = request.getConfig(this);
Gson gson = new Gson();
Map<String, Object> conf = new HashMap<>();
// convert according to the actual configured conf type
conf = gson.fromJson(configStr, conf.getClass());
String k1 = request.getVars("uri");
String endP = k1.split("/")[1];
log.info("nginx_uri: " + k1);
log.info("is_args: " + request.getVars("is_args"));
chain.filter(request, response);
}
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
log.info("--------------------post filter start------------11111111");
// log.info(request.getUpstreamHeaders().toString());
log.info(request.getUpstreamStatusCode().toString());
log.info(request.getBody());
log.info("--------------------post filter end------------11111111");
chain.postFilter(request, response);
}
@Override
public List<String> requiredVars() {
List<String> vars = new ArrayList<>();
return vars;
}
@Override
public Boolean requiredBody() {
return true;
}
@Override
public Boolean requiredRespBody() {
return true;
}
my upstream(127.0.0.1:8080) info
@GetMapping("/bodybody*")
public ResponseEntity fea2A2s2sbcd22d31222212d(@RequestHeader Map<String, String> headers) throws Exception {
for (Map.Entry<String, String> entry : headers.entrySet()) {
System.out.println("key: " + entry.getKey() + ", value: " + entry.getValue());
}
HttpHeaders aaHeaders = new HttpHeaders();
aaHeaders.add("test", "1234");
if (headers.get("error") != null & headers.get("error").equals("400")) {
return new ResponseEntity(user, aaHeaders, HttpStatus.BAD_REQUEST);
} else if (headers.get("error") != null & headers.get("error").equals("100")) {
throw new Exception();
}
return new ResponseEntity(aaHeaders, HttpStatus.OK);
}
when upstream throws an exception, log status value is 0. u can repro with my info @nic-chen
Issue description
When the upstream response status is 400 or 500, the postfilter cannot check the status.
my post filter is
When the upstream responds with 200, the log is
but, 400 or 500
I want to process logic based on the upstream response status(200, 400, 500) can u check this problems? @nic-chen
and one more thing.. In about half of all calls, postfilter throws java.lang.IndexOutOfBoundsException: null. error.log is
TestFilter.java:127 line is 'log.info(request.getUpstreamHeaders().toString())'
thx in advance
Environment
apisix 3.2.0, 3.2.1 apisix-java-plugin-runner 0.4.0