You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "joyyir (via GitHub)" <gi...@apache.org> on 2023/05/22 04:14:29 UTC

[GitHub] [apisix-java-plugin-runner] joyyir opened a new issue, #243: bug: `ExtraInfoResponse` class `getResult` method bug

joyyir opened a new issue, #243:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/243

   ### Issue description
   There is a bug in the `getResult` method of the `ExtraInfoResponse` class.
   If the encoding of the upstream response is not 'UTF-8', The result string is broken.
   In my opinion, instead of casting to `char`, casting to `byte` is the correct way.
   
   ```java
       public String getResult() {
           StringBuilder builder = new StringBuilder();
           for (int i = 0; i < this.resp.resultLength(); i++) {
               builder.append((char) this.resp.result(i));
           }
           return builder.toString();
       }
   ```
   
   ```java
       public byte[] getResult() {
           byte[] byteArray = new byte[this.resp.resultLength()];
           for (int i = 0; i < this.resp.resultLength(); i++) {
               byteArray[i] = (byte) this.resp.result(i);
           }
           return byteArray;
   ```
   
   ### Environment
   
   * your apisix-java-plugin-runner version
   0.4.0
   
   ### Minimal test code / Steps to reproduce the issue
   
   1. set Upstream which produces response other than `UTF-8` encoding
   2. set `ext-plugin-post-resp` plugin setting in ApisixRoute
   3. log the result of PostRequest getBody() in `postFilter` method
   
   ### What's the actual result? (including assertion message & call stack if applicable)
   broken string
   
   ### What's the expected result?
   normal string


-- 
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: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-java-plugin-runner] joyyir closed issue #243: bug: `ExtraInfoResponse` class `getResult` method bug

Posted by "joyyir (via GitHub)" <gi...@apache.org>.
joyyir closed issue #243: bug: `ExtraInfoResponse` class `getResult` method bug
URL: https://github.com/apache/apisix-java-plugin-runner/issues/243


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org