Skip to content

Commit

Permalink
Update LittleProxy from 2.0.5 to 2.0.20 (#150)
Browse files Browse the repository at this point in the history
* use a request duplicate to create new HttpPostRequestDecoder in HttpRequestWrapper to avoid side effect on reader index
* added comment about SL4J 2
  • Loading branch information
WolfgangHG authored Sep 6, 2023
1 parent d95d166 commit fcc5c43
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion extension/jsf-ftest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<!--This binds to SLF4J 1.7.29 - same that is used by LittleProxy 1.1.2 -->
<!--This binds to SLF4J 1.7.29 - same that is used up to LittleProxy 2.0.7.
More recent LittleProxy versions use "log4j-slf4j2-impl", but several other dependencies still provide the 1.x version, and
thus we would have to add a dependency "org.slf4:slf4j-api:2.0.7" to overwrite the other version. It is easier to stay with 1.x-->
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
Expand Down
4 changes: 3 additions & 1 deletion ftest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<!--This binds to SLF4J 1.7.29 - same that is used by LittleProxy 1.1.2 -->
<!--This binds to SLF4J 1.7.29 - same that is used up to LittleProxy 2.0.7.
More recent LittleProxy versions use "log4j-slf4j2-impl", but several other dependencies still provide the 1.x version, and
thus we would have to add a dependency "org.slf4:slf4j-api:2.0.7" to overwrite the other version. It is easier to stay with 1.x-->
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package org.jboss.arquillian.warp.impl.client.execution;

import io.netty.handler.codec.http.HttpContent;
import io.netty.handler.codec.http.HttpRequest;
import io.netty.handler.codec.http.QueryStringDecoder;
import io.netty.handler.codec.http.multipart.Attribute;
Expand Down Expand Up @@ -115,8 +116,17 @@ public Map<String, List<String>> getHttpDataAttributes() {

try {
if (httpDataAttributes == null) {
//Workaround for issue 134: creating "HttpPostRequestDecoder" changes the reader index of the "request" object,
//thus no body data is sent to the server.
//The request has to be duplicated before.
//Don't call "release()" on the duplicate, as it would also release the original object.
//The request variable is a "io.netty.handler.codec.http.FullHttpMessage", which implements "HttpContext".
HttpContent content = (HttpContent) request;
HttpContent contentDuplicated = content.duplicate();

final HttpPostRequestDecoder decoder =
new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), request);
new HttpPostRequestDecoder(new DefaultHttpDataFactory(false), (HttpRequest) contentDuplicated);

final Map<String, List<String>> map = new HashMap<String, List<String>>();

try {
Expand All @@ -133,6 +143,7 @@ public Map<String, List<String>> getHttpDataAttributes() {
list.add(attribute.getValue());
}
}

} finally {
decoder.destroy();
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<version.arquillian_drone>3.0.0-alpha.7</version.arquillian_drone>
<version.arquillian_jacoco>1.1.0</version.arquillian_jacoco>

<version.littleproxy>2.0.5</version.littleproxy>
<version.littleproxy>2.0.20</version.littleproxy>
<!--Littleproxy logging is done through SL4J and thus Log4j: -->
<version.log4j>2.20.0</version.log4j>
<version.javassist>3.29.2-GA</version.javassist>
Expand Down

0 comments on commit fcc5c43

Please sign in to comment.