Open 108825446 opened 1 year ago
com.taikang.tlife.activity.apisix.plugins.fliters.ClientAuthenticationFilter.postFilter(ClientAuthenticationFilter.java:85)
Is this the NPE in your private code?
yes, it the plugin of the authentication, the implement fo the plugin is like below:
@Component public class ClientAuthenticationFilter implements PluginFilter {
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
log.warn("ClientAuthenticationFilter is running");
log.warn("status:{}", request.getUpstreamStatusCode());
**//i want to get the upstream body, but it cant , the reponseBody is null, so it throws the NullPointerException**
String responseBody = request.getBody();
String authResult = processAuthResult(responseBody );
response.setBody(authResult );
chain.postFilter(request, response);
}
whihe line cause the NPE? You need to give detailed steps for reproduction.
The line String responseBody = request.getBody(); the responseBody is null, when process it in processAuthResult, it throws NullPointerException. I want to know how to get the upstream reponse content. because the " request.getBody()" cant get the upstream body.
the responseBody is null, when process it in processAuthResult, it throws NullPointerException.
You need to give detailed steps for reproduction.
a good reproduct describtion like: https://github.com/apache/apisix-java-plugin-runner/issues/189#issuecomment-1226756930
do you add those lines?
/**
* If you need to fetch request body in the current plugin, you will need to return true in this function.
*/
@Override
public Boolean requiredRespBody() {
return true;
}
/**
* If you need to fetch request body in the current plugin, you will need to return true in this function.
*/
@Override
public Boolean requiredBody() {
return true;
}
Issue description
I want to get the upstream response content in the plugin for processing and then return to the client, but it return null This is how the class is handled: @Override public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) { log.warn("ClientAuthenticationFilter is running");
java.lang.NullPointerException: null postFilter(ClientAuthenticationFilter.java:85)
Environment