Skip to content

Commit d20a4d8

Browse files
committed
camelCase
1 parent 0c68966 commit d20a4d8

File tree

9 files changed

+32
-44
lines changed

9 files changed

+32
-44
lines changed

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/StandardTestClientBuilder.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ final class StandardTestClientBuilder implements TestClientBuilder {
5757

5858
private HttpClientConnectionManager connectionManager;
5959

60-
private boolean nowrap;
60+
private boolean noWrap;
6161

6262
public StandardTestClientBuilder() {
6363
this.clientBuilder = HttpClientBuilder.create();
@@ -75,8 +75,8 @@ public TestClientBuilder setTimeout(final Timeout timeout) {
7575
}
7676

7777
@Override
78-
public TestClientBuilder setnowrap(final boolean nowrap) {
79-
this.nowrap = nowrap;
78+
public TestClientBuilder setNoWrap(final boolean noWrap) {
79+
this.noWrap = noWrap;
8080
return this;
8181
}
8282

@@ -173,7 +173,7 @@ public TestClient build() throws Exception {
173173

174174
final CloseableHttpClient client = clientBuilder
175175
.setConnectionManager(connectionManagerCopy)
176-
.setNowrap(nowrap)
176+
.setNoWrap(noWrap)
177177
.build();
178178
return new TestClient(client, connectionManagerCopy);
179179
}

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ default TestClientBuilder addExecInterceptorLast(String name, ExecChainHandler
9898
throw new UnsupportedOperationException("Operation not supported by " + getProtocolLevel());
9999
}
100100

101-
default TestClientBuilder setnowrap(boolean nowrap){
101+
default TestClientBuilder setNoWrap(boolean noWrap){
102102
return this;
103103
}
104104

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/extension/sync/TestClientResources.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ public TestClient client() throws Exception {
118118
return client;
119119
}
120120

121-
public TestClient client(final boolean nowrap) throws Exception {
122-
clientBuilder.setnowrap(nowrap);
121+
public TestClient client(final boolean noWrap) throws Exception {
122+
clientBuilder.setNoWrap(noWrap);
123123
return client();
124124
}
125125

httpclient5-testing/src/test/java/org/apache/hc/client5/testing/sync/AbstractIntegrationTestBase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public TestClient client() throws Exception {
7878
return testResources.client();
7979
}
8080

81-
public TestClient client(final boolean nowrap) throws Exception {
82-
return testResources.client(nowrap);
81+
public TestClient client(final boolean noWrap) throws Exception {
82+
return testResources.client(noWrap);
8383
}
8484

8585
}

httpclient5/src/main/java/org/apache/hc/client5/http/entity/DecompressEntity.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,32 +31,29 @@
3131
import java.io.OutputStream;
3232

3333
import org.apache.commons.io.IOUtils;
34+
import org.apache.hc.core5.annotation.Contract;
35+
import org.apache.hc.core5.annotation.ThreadingBehavior;
3436
import org.apache.hc.core5.http.HttpEntity;
3537
import org.apache.hc.core5.http.io.entity.HttpEntityWrapper;
3638
import org.apache.hc.core5.util.Args;
3739

3840
/**
3941
* An {@link HttpEntity} wrapper that decompresses the content of the wrapped entity.
40-
* This class supports various compression types such as "gzip", "deflate", and others.
41-
* It also handles variations like noWrap, where zlib headers and trailers are omitted.
42+
* This class supports different compression types and can handle both standard
43+
* compression (e.g., gzip, deflate) and variations that require a custom handling (e.g., noWrap).
4244
*
43-
* <p>
44-
* Decompression is performed lazily through a {@link LazyDecompressInputStream}, which
45-
* initializes the decompression stream only when the content is requested.
46-
* </p>
47-
*
48-
* <p>
49-
* <b>Content Length:</b> Since the content is being decompressed, the exact content length is
50-
* unknown, and as such, this class returns the content length of the wrapped entity.
51-
* </p>
45+
* <p>Decompression is performed using a {@link LazyDecompressInputStream} that
46+
* applies decompression lazily when content is requested.</p>
5247
*
5348
* <p>
54-
* Note: This class is <b>not thread-safe</b>. If multiple threads access an instance of this class concurrently,
55-
* they must synchronize on the instance to ensure correct behavior.
49+
* Note: This class uses lazy initialization for certain fields, making it <b>not thread-safe</b>.
50+
* If multiple threads access an instance of this class concurrently, they must synchronize on the instance
51+
* to ensure correct behavior.
5652
* </p>
5753
*
5854
* @since 5.5
5955
*/
56+
@Contract(threading = ThreadingBehavior.UNSAFE)
6057
public class DecompressEntity extends HttpEntityWrapper {
6158

6259
/**

httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ContentCompressionExec.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ public final class ContentCompressionExec implements ExecChainHandler {
7474
private final Header acceptEncoding;
7575
final List<String> normalizedEncodings;
7676
private final boolean ignoreUnknown;
77-
private final boolean nowrap;
77+
private final boolean noWrap;
7878

7979
public ContentCompressionExec(
8080
final List<String> acceptEncoding,
8181
final boolean ignoreUnknown,
82-
final boolean nowrap) {
82+
final boolean noWrap) {
8383

8484
if (acceptEncoding != null) {
8585
this.normalizedEncodings = acceptEncoding.stream()
@@ -95,15 +95,15 @@ public ContentCompressionExec(
9595

9696
this.ignoreUnknown = ignoreUnknown;
9797

98-
this.nowrap = nowrap;
98+
this.noWrap = noWrap;
9999
}
100100

101101
public ContentCompressionExec(final boolean ignoreUnknown) {
102102
this(null, ignoreUnknown, false);
103103
}
104104

105-
public ContentCompressionExec(final boolean ignoreUnknown, final boolean nowrap) {
106-
this(null, ignoreUnknown, nowrap);
105+
public ContentCompressionExec(final boolean ignoreUnknown, final boolean noWrap) {
106+
this(null, ignoreUnknown, noWrap);
107107
}
108108

109109

@@ -151,7 +151,7 @@ public ClassicHttpResponse execute(
151151
for (final HeaderElement codec : codecs) {
152152
final String codecname = CompressorFactory.INSTANCE.getFormattedName(codec.getName());
153153
if (normalizedEncodings.contains(codecname)) {
154-
response.setEntity(new DecompressEntity(response.getEntity(), codecname, nowrap));
154+
response.setEntity(new DecompressEntity(response.getEntity(), codecname, noWrap));
155155
response.removeHeaders(HttpHeaders.CONTENT_LENGTH);
156156
response.removeHeaders(HttpHeaders.CONTENT_ENCODING);
157157
response.removeHeaders(HttpHeaders.CONTENT_MD5);

httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/HttpClientBuilder.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ private ExecInterceptorEntry(
234234

235235
private List<String> encodings;
236236

237-
private boolean nowrap;
237+
private boolean noWrap;
238238

239239
public static HttpClientBuilder create() {
240240
return new HttpClientBuilder();
@@ -708,7 +708,6 @@ public final HttpClientBuilder setContentDecoderRegistry(
708708
return this;
709709
}
710710

711-
712711
/**
713712
* Sets the list of content encodings to be supported for automatic content compression and decompression.
714713
* <p>
@@ -737,19 +736,19 @@ public final HttpClientBuilder setEncodings(final List<String> encodings) {
737736
}
738737

739738
/**
740-
* Sets the "nowrap" option for the HTTP client.
739+
* Sets the "noWrap" option for the HTTP client.
741740
* <p>
742741
* When enabled, this option disables the zlib header and trailer in deflate compression streams.
743742
* This is useful when working with servers that require or expect raw deflate streams without
744743
* the standard zlib header and trailer.
745744
* </p>
746745
*
747-
* @param nowrap if {@code true}, disables the zlib header and trailer in deflate streams.
746+
* @param noWrap if {@code true}, disables the zlib header and trailer in deflate streams.
748747
* @return the updated {@link HttpClientBuilder} instance.
749748
* @since 5.4
750749
*/
751-
public final HttpClientBuilder setNowrap(final boolean nowrap) {
752-
this.nowrap = nowrap;
750+
public final HttpClientBuilder setNoWrap(final boolean noWrap) {
751+
this.noWrap = noWrap;
753752
return this;
754753
}
755754

@@ -1045,10 +1044,10 @@ public CloseableHttpClient build() {
10451044
if (!contentCompressionDisabled) {
10461045
if (encodings != null && !encodings.isEmpty()) {
10471046
execChainDefinition.addFirst(
1048-
new ContentCompressionExec(encodings, true, nowrap),
1047+
new ContentCompressionExec(encodings, true, noWrap),
10491048
ChainElement.COMPRESS.name());
10501049
} else {
1051-
execChainDefinition.addFirst(new ContentCompressionExec(true, nowrap), ChainElement.COMPRESS.name());
1050+
execChainDefinition.addFirst(new ContentCompressionExec(true, noWrap), ChainElement.COMPRESS.name());
10521051
}
10531052
}
10541053

httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestEntityBuilder.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,14 @@ void testBuildGZipped() {
130130

131131
@Test
132132
public void testCompressionDecompression() throws Exception {
133-
134133
final String originalContent = "some kind of text";
135134
final StringEntity originalEntity = new StringEntity(originalContent, ContentType.TEXT_PLAIN);
136-
137135
final HttpEntity compressedEntity = CompressorFactory.INSTANCE.compressEntity(originalEntity, "gz");
138-
139136
final ByteArrayOutputStream compressedOut = new ByteArrayOutputStream();
140137
compressedEntity.writeTo(compressedOut);
141-
142138
final ByteArrayEntity out = new ByteArrayEntity(compressedOut.toByteArray(), ContentType.APPLICATION_OCTET_STREAM);
143-
144139
final HttpEntity decompressedEntity = CompressorFactory.INSTANCE.decompressEntity(out, "gz");
145-
146140
final String decompressedContent = EntityUtils.toString(decompressedEntity, StandardCharsets.UTF_8);
147-
148141
Assertions.assertEquals(originalContent, decompressedContent, "The decompressed content should match the original content.");
149142
}
150143

httpclient5/src/test/java/org/apache/hc/client5/http/entity/TestGZip.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ void testCompressionDecompression() throws Exception {
7676
Assertions.assertEquals("some kind of text", EntityUtils.toString(gunzipe, StandardCharsets.US_ASCII));
7777
}
7878

79-
8079
@Test
8180
void testCompressionIOExceptionLeavesOutputStreamOpen() throws Exception {
8281
final HttpEntity in = Mockito.mock(HttpEntity.class);

0 commit comments

Comments
 (0)