MariaLapovska opened a new pull request, #326: URL: https://github.com/apache/apisix-java-plugin-runner/pull/326
Please answer these questions before submitting a pull request - Why submit this pull request? - [x] Bugfix - [ ] New feature provided - [ ] Improve performance - Related issues - https://github.com/apache/apisix-java-plugin-runner/issues/325 - https://github.com/apache/apisix-java-plugin-runner/issues/228 - https://github.com/apache/apisix-java-plugin-runner/issues/234 ___ ### Bugfix - Description Currently, if you try to call PostRequest.getUpstreamHeaders() in postFilter(), it **intermittently** throws IndexOutOfBoundsException (specifically headersLength() method in Req class): ``` java.lang.IndexOutOfBoundsException: null at java.base/java.nio.Buffer$1.apply(Buffer.java:757) ~[na:na] at java.base/java.nio.Buffer$1.apply(Buffer.java:754) ~[na:na] at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) ~[na:na] at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) ~[na:na] at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) ~[na:na] at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) ~[na:na] at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) ~[na:na] at java.base/java.nio.Buffer.checkIndex(Buffer.java:779) ~[na:na] at java.base/java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:761) ~[na:na] at com.google.flatbuffers.Table.__vector_len(Table.java:125) ~[flatbuffers-java-2.0.0.jar!/:na] at io.github.api7.A6.HTTPRespCall.Req.headersLength(Req.java:22) ~[A6-0.6.0-RELEASE.jar!/:na] at org.apache.apisix.plugin.runner.PostRequest.getUpstreamHeaders(PostRequest.java:82) ~[apisix-runner-plugin-sdk-0.6.0.jar!/:0.6.0] at gg.lita.arch.gateway.plugin.filters.LitaLoginResponseFilter.getPostRequestHeaders(LitaLoginResponseFilter.java:52) ~[!/:0.0.1] ``` - How to fix? If we follow the same pattern as RpcHandler does with HttpRequest, where it pre-reads the headers, we avoid the given issue, where by the time PostRequest.getUpstreamHeaders() is called from inside one of the plugins, the ByteBuffer could be corrupted, reused, or have a wrong position. -- 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]
