Skip to content

Commit 007a5f6

Browse files
committed
Upgraded HC StyleCheck to version 3; fixed style-check violations (no functional changes)
1 parent e9560a4 commit 007a5f6

File tree

125 files changed

+619
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+619
-612
lines changed

httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/CacheContextBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ protected HttpCacheContext createContext() {
109109

110110
@Override
111111
public HttpCacheContext build() {
112-
final HttpCacheContext context = super.build();
112+
final HttpCacheContext context = super.build();
113113
context.setRequestCacheControl(cacheControl);
114114
return context;
115115
}

httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ public class HeaderConstants {
165165
public static final String CACHE_CONTROL_STALE_WHILE_REVALIDATE = "stale-while-revalidate";
166166
public static final String CACHE_CONTROL_ONLY_IF_CACHED = "only-if-cached";
167167
public static final String CACHE_CONTROL_MUST_UNDERSTAND = "must-understand";
168-
public static final String CACHE_CONTROL_IMMUTABLE= "immutable";
168+
public static final String CACHE_CONTROL_IMMUTABLE = "immutable";
169+
169170
/**
170171
* @deprecated Use {@link #CACHE_CONTROL_STALE_IF_ERROR}
171172
*/

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ private void handleCacheHit(
721721
final AsyncExecChain.Scope scope,
722722
final AsyncExecChain chain,
723723
final AsyncExecCallback asyncExecCallback) {
724-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
724+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
725725
final String exchangeId = scope.exchangeId;
726726

727727
if (LOG.isDebugEnabled()) {

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CacheConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ public int getMaxCacheEntries() {
227227
/**
228228
* Returns the number of times to retry a cache processChallenge on failure
229229
*/
230-
public int getMaxUpdateRetries(){
230+
public int getMaxUpdateRetries() {
231231
return maxUpdateRetries;
232232
}
233233

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedResponseSuitabilityChecker.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ public CacheSuitability assessSuitability(final RequestCacheControl requestCache
198198

199199
boolean requestMethodMatch(final HttpRequest request, final HttpCacheEntry entry) {
200200
return request.getMethod().equalsIgnoreCase(entry.getRequestMethod()) ||
201-
(Method.HEAD.isSame(request.getMethod()) && Method.GET.isSame(entry.getRequestMethod()));
201+
Method.HEAD.isSame(request.getMethod()) && Method.GET.isSame(entry.getRequestMethod());
202202
}
203203

204204
boolean requestUriMatch(final HttpRequest request, final HttpCacheEntry entry) {
@@ -295,10 +295,10 @@ public boolean allConditionalsMatch(final HttpRequest request, final HttpCacheEn
295295
return true;
296296
}
297297

298-
final boolean etagValidatorMatches = (hasEtagValidator) && etagValidatorMatches(request, entry);
299-
final boolean lastModifiedValidatorMatches = (hasLastModifiedValidator) && lastModifiedValidatorMatches(request, entry, now);
298+
final boolean etagValidatorMatches = hasEtagValidator && etagValidatorMatches(request, entry);
299+
final boolean lastModifiedValidatorMatches = hasLastModifiedValidator && lastModifiedValidatorMatches(request, entry, now);
300300

301-
if ((hasEtagValidator && hasLastModifiedValidator)
301+
if (hasEtagValidator && hasLastModifiedValidator
302302
&& !(etagValidatorMatches && lastModifiedValidatorMatches)) {
303303
return false;
304304
} else if (hasEtagValidator && !etagValidatorMatches) {
@@ -309,9 +309,9 @@ public boolean allConditionalsMatch(final HttpRequest request, final HttpCacheEn
309309
}
310310

311311
boolean hasUnsupportedConditionalHeaders(final HttpRequest request) {
312-
return (request.containsHeader(HttpHeaders.IF_RANGE)
312+
return request.containsHeader(HttpHeaders.IF_RANGE)
313313
|| request.containsHeader(HttpHeaders.IF_MATCH)
314-
|| request.containsHeader(HttpHeaders.IF_UNMODIFIED_SINCE));
314+
|| request.containsHeader(HttpHeaders.IF_UNMODIFIED_SINCE);
315315
}
316316

317317
boolean hasSupportedEtagValidator(final HttpRequest request) {

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingExec.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ ClassicHttpResponse callBackend(
218218
final HttpHost target,
219219
final ClassicHttpRequest request,
220220
final ExecChain.Scope scope,
221-
final ExecChain chain) throws IOException, HttpException {
221+
final ExecChain chain) throws IOException, HttpException {
222222

223223
final String exchangeId = scope.exchangeId;
224224
final Instant requestDate = getCurrentDate();
@@ -244,7 +244,7 @@ private ClassicHttpResponse handleCacheHit(
244244
final ExecChain.Scope scope,
245245
final ExecChain chain) throws IOException, HttpException {
246246
final String exchangeId = scope.exchangeId;
247-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
247+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
248248

249249
if (LOG.isDebugEnabled()) {
250250
LOG.debug("{} cache hit: {}", exchangeId, new RequestLine(request));
@@ -353,7 +353,7 @@ ClassicHttpResponse revalidateCacheEntry(
353353
final ClassicHttpRequest request,
354354
final ExecChain.Scope scope,
355355
final ExecChain chain) throws IOException, HttpException {
356-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
356+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
357357
Instant requestDate = getCurrentDate();
358358
final ClassicHttpRequest conditionalRequest = conditionalRequestBuilder.buildConditionalRequest(
359359
responseCacheControl, request, hit.entry);
@@ -397,7 +397,7 @@ ClassicHttpResponse revalidateCacheEntryWithoutFallback(
397397
final ExecChain.Scope scope,
398398
final ExecChain chain) throws HttpException {
399399
final String exchangeId = scope.exchangeId;
400-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
400+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
401401
try {
402402
return revalidateCacheEntry(responseCacheControl, hit, target, request, scope, chain);
403403
} catch (final IOException ex) {
@@ -418,7 +418,7 @@ ClassicHttpResponse revalidateCacheEntryWithFallback(
418418
final ExecChain.Scope scope,
419419
final ExecChain chain) throws HttpException, IOException {
420420
final String exchangeId = scope.exchangeId;
421-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
421+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
422422
final ClassicHttpResponse response;
423423
try {
424424
response = revalidateCacheEntry(responseCacheControl, hit, target, request, scope, chain);
@@ -490,7 +490,7 @@ ClassicHttpResponse cacheAndReturnResponse(
490490
final Instant requestSent,
491491
final Instant responseReceived) throws IOException {
492492
final String exchangeId = scope.exchangeId;
493-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
493+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
494494
final int statusCode = backendResponse.getCode();
495495
// handle 304 Not Modified responses
496496
if (statusCode == HttpStatus.SC_NOT_MODIFIED) {
@@ -573,7 +573,7 @@ private ClassicHttpResponse handleCacheMiss(
573573
}
574574
cacheMisses.getAndIncrement();
575575

576-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
576+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
577577
if (requestCacheControl.isOnlyIfCached()) {
578578
if (LOG.isDebugEnabled()) {
579579
LOG.debug("{} request marked only-if-cached", exchangeId);
@@ -643,7 +643,7 @@ ClassicHttpResponse negotiateResponseFromVariants(
643643
return callBackend(target, unconditional, scope, chain);
644644
}
645645

646-
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
646+
final HttpCacheContext context = HttpCacheContext.cast(scope.clientContext);
647647
context.setCacheResponseStatus(CacheResponseStatus.VALIDATED);
648648
cacheUpdates.getAndIncrement();
649649

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ManagedHttpCacheStorage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ public boolean isActive() {
240240
return active.get();
241241
}
242242

243-
private boolean compareAndSet(){
243+
private boolean compareAndSet() {
244244
return this.active.compareAndSet(true, false);
245245
}
246+
246247
}

httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ResponseCachingPolicy.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ protected boolean isExplicitlyNonCacheable(final ResponseCacheControl cacheContr
235235
// The response is considered explicitly non-cacheable if it contains
236236
// "no-store" or (if sharedCache is true) "private" directives.
237237
// Note that "no-cache" is considered cacheable but requires validation before use.
238-
return cacheControl.isNoStore() || (sharedCache && cacheControl.isCachePrivate());
238+
return cacheControl.isNoStore() || sharedCache && cacheControl.isCachePrivate();
239239
}
240240

241241
protected boolean isExplicitlyCacheable(final ResponseCacheControl cacheControl, final HttpResponse response) {
@@ -371,11 +371,11 @@ private Duration calculateFreshnessLifetime(final ResponseCacheControl cacheCont
371371
* @return true if the HTTP status code is understood, false otherwise.
372372
*/
373373
private boolean understoodStatusCode(final int status) {
374-
return (status >= 200 && status <= 206) ||
375-
(status >= 300 && status <= 399) ||
376-
(status >= 400 && status <= 417) ||
377-
(status == 421) ||
378-
(status >= 500 && status <= 505);
374+
return status >= 200 && status <= 206 ||
375+
status >= 300 && status <= 399 ||
376+
status >= 400 && status <= 417 ||
377+
status == 421 ||
378+
status >= 500 && status <= 505;
379379
}
380380

381381
/**

httpclient5-cache/src/test/java/org/apache/hc/client5/http/cache/TestHttpCacheEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ void canGetOriginalHeaders() {
176176
entry = makeEntry(Instant.now(), Instant.now(), HttpStatus.SC_OK, headers, mockResource, null);
177177
final Header[] result = entry.getHeaders();
178178
assertEquals(headers.length, result.length);
179-
for(int i=0; i<headers.length; i++) {
179+
for (int i = 0; i < headers.length; i++) {
180180
assertEquals(headers[i], result[i]);
181181
}
182182
}

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/HttpTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static boolean equivalent(final HttpEntity e1, final HttpEntity e2) throw
8080
return false;
8181
}
8282
}
83-
return (-1 == i2.read());
83+
return -1 == i2.read();
8484
}
8585

8686
/*

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingAsyncCacheStorage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public static byte[] serialize(final String key, final HttpCacheEntry value) thr
7373

7474
@BeforeEach
7575
@SuppressWarnings("unchecked")
76-
public void setUp() {
76+
void setUp() {
7777
MockitoAnnotations.openMocks(this);
7878
impl = Mockito.mock(AbstractBinaryAsyncCacheStorage.class,
7979
Mockito.withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS).useConstructor(3));

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestAbstractSerializingCacheStorage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static byte[] serialize(final String key, final HttpCacheEntry value) thr
6161

6262
@BeforeEach
6363
@SuppressWarnings("unchecked")
64-
public void setUp() {
64+
void setUp() {
6565
impl = Mockito.mock(AbstractBinaryCacheStorage.class,
6666
Mockito.withSettings().defaultAnswer(Answers.CALLS_REAL_METHODS).useConstructor(3));
6767
}
@@ -125,7 +125,7 @@ void testCacheGetKeyMismatch() throws Exception {
125125
}
126126

127127
@Test
128-
void testCacheRemove() throws Exception{
128+
void testCacheRemove() throws Exception {
129129
final String key = "foo";
130130

131131
when(impl.digestToStorageKey(key)).thenReturn("bar");

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestCacheValidityPolicy.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void testApparentAgeIsResponseReceivedTimeLessDateHeader() {
8080
@Test
8181
void testNegativeApparentAgeIsBroughtUpToZero() {
8282
final Header[] headers = new Header[] { new BasicHeader("Date", DateUtils.formatStandardDate(sixSecondsAgo)) };
83-
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, tenSecondsAgo, headers);
83+
final HttpCacheEntry entry = HttpTestUtils.makeCacheEntry(now, tenSecondsAgo, headers);
8484
assertEquals(TimeValue.ofSeconds(0), impl.getApparentAge(entry));
8585
}
8686

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestHttpByteArrayCacheEntrySerializer.java

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -399,36 +399,36 @@ void testSimpleVariantMap() throws Exception {
399399
*/
400400
@Test
401401
void testDeserializeCacheEntryWithTrailingGarbage() {
402-
final String content1 =HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" +
402+
final String content1 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" +
403403
"HC-Key: unique-cache-key\n" +
404-
"HC-Resource-Length: 11\n" +
405-
"HC-Request-Instant: 1686210849596\n" +
406-
"HC-Response-Instant: 1686210849596\n" +
407-
"\n" +
408-
"GET /stuff HTTP/1.1\n" +
409-
"\n" +
410-
"HTTP/1.1 200 \n" +
411-
"Content-Type: text/plain; charset=UTF-8\n" +
412-
"Cache-control: public, max-age=31536000\n" +
413-
"\n" +
414-
"Hello World..... Rubbish";
404+
"HC-Resource-Length: 11\n" +
405+
"HC-Request-Instant: 1686210849596\n" +
406+
"HC-Response-Instant: 1686210849596\n" +
407+
"\n" +
408+
"GET /stuff HTTP/1.1\n" +
409+
"\n" +
410+
"HTTP/1.1 200 \n" +
411+
"Content-Type: text/plain; charset=UTF-8\n" +
412+
"Cache-control: public, max-age=31536000\n" +
413+
"\n" +
414+
"Hello World..... Rubbish";
415415
final byte[] bytes1 = content1.getBytes(StandardCharsets.UTF_8);
416416
final ResourceIOException exception1 = Assertions.assertThrows(ResourceIOException.class, () ->
417417
httpCacheEntrySerializer.deserialize(bytes1));
418418
Assertions.assertEquals("Unexpected content at the end of cache content", exception1.getMessage());
419419

420-
final String content2 =HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" +
420+
final String content2 = HttpByteArrayCacheEntrySerializer.HC_CACHE_VERSION_LINE + "\n" +
421421
"HC-Key: unique-cache-key\n" +
422-
"HC-Request-Instant: 1686210849596\n" +
423-
"HC-Response-Instant: 1686210849596\n" +
424-
"\n" +
425-
"GET /stuff HTTP/1.1\n" +
426-
"\n" +
427-
"HTTP/1.1 200 \n" +
428-
"Content-Type: text/plain; charset=UTF-8\n" +
429-
"Cache-control: public, max-age=31536000\n" +
430-
"\n" +
431-
"Rubbish";
422+
"HC-Request-Instant: 1686210849596\n" +
423+
"HC-Response-Instant: 1686210849596\n" +
424+
"\n" +
425+
"GET /stuff HTTP/1.1\n" +
426+
"\n" +
427+
"HTTP/1.1 200 \n" +
428+
"Content-Type: text/plain; charset=UTF-8\n" +
429+
"Cache-control: public, max-age=31536000\n" +
430+
"\n" +
431+
"Rubbish";
432432
final byte[] bytes2 = content2.getBytes(StandardCharsets.UTF_8);
433433
final ResourceIOException exception2 = Assertions.assertThrows(ResourceIOException.class, () ->
434434
httpCacheEntrySerializer.deserialize(bytes2));

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRecommendations.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ private void testDoesNotReturnStaleResponseOnError(final ClassicHttpRequest req2
268268
ClassicHttpResponse result = null;
269269
try {
270270
result = execute(req2);
271-
} catch (final IOException acceptable) {
271+
} catch (final IOException expected) {
272272
}
273273

274274
if (result != null) {
@@ -745,8 +745,8 @@ void testSendsAllVariantEtagsInConditionalRequest() throws Exception {
745745
final ClassicHttpRequest captured = reqCapture.getValue();
746746
boolean foundEtag1 = false;
747747
boolean foundEtag2 = false;
748-
for(final Header h : captured.getHeaders("If-None-Match")) {
749-
for(final String etag : h.getValue().split(",")) {
748+
for (final Header h : captured.getHeaders("If-None-Match")) {
749+
for (final String etag : h.getValue().split(",")) {
750750
if ("\"etag1\"".equals(etag.trim())) {
751751
foundEtag1 = true;
752752
}

httpclient5-cache/src/test/java/org/apache/hc/client5/http/impl/cache/TestProtocolRequirements.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ void testCachedEntityBodyIsUsedForResponseAfter304Validation() throws Exception
12121212
try (final InputStream i1 = resp1.getEntity().getContent();
12131213
final InputStream i2 = result.getEntity().getContent()) {
12141214
int b1, b2;
1215-
while((b1 = i1.read()) != -1) {
1215+
while ((b1 = i1.read()) != -1) {
12161216
b2 = i2.read();
12171217
Assertions.assertEquals(b1, b2);
12181218
}
@@ -1262,7 +1262,7 @@ void testResponseIncludesCacheEntryEndToEndHeadersForResponseAfter304Validation(
12621262
"Content-MD5", "Content-Type", "Expires", "Last-Modified",
12631263
"Location", "Retry-After"
12641264
};
1265-
for(final String h : endToEndHeaders) {
1265+
for (final String h : endToEndHeaders) {
12661266
Assertions.assertEquals(HttpTestUtils.getCanonicalHeaderValue(resp1, h),
12671267
HttpTestUtils.getCanonicalHeaderValue(result, h));
12681268
}
@@ -1306,7 +1306,7 @@ void testUpdatedEndToEndHeadersFrom304ArePassedOnResponseAndUpdatedInCacheEntry(
13061306
"Content-Location", "Content-Type", "Expires", "Location",
13071307
"Retry-After"
13081308
};
1309-
for(final String h : endToEndHeaders) {
1309+
for (final String h : endToEndHeaders) {
13101310
Assertions.assertEquals(HttpTestUtils.getCanonicalHeaderValue(resp2, h),
13111311
HttpTestUtils.getCanonicalHeaderValue(result1, h));
13121312
Assertions.assertEquals(HttpTestUtils.getCanonicalHeaderValue(resp2, h),
@@ -2093,7 +2093,7 @@ void testOrderOfMultipleContentEncodingHeaderValuesIsPreserved() throws Exceptio
20932093
final Iterator<HeaderElement> it = MessageSupport.iterate(result, HttpHeaders.CONTENT_ENCODING);
20942094
while (it.hasNext()) {
20952095
final HeaderElement elt = it.next();
2096-
switch(total_encodings) {
2096+
switch (total_encodings) {
20972097
case 0:
20982098
Assertions.assertEquals("gzip", elt.getName());
20992099
break;
@@ -2118,7 +2118,7 @@ void testOrderOfMultipleParametersInContentEncodingHeaderIsPreserved() throws Ex
21182118
final Iterator<HeaderElement> it = MessageSupport.iterate(result, HttpHeaders.CONTENT_ENCODING);
21192119
while (it.hasNext()) {
21202120
final HeaderElement elt = it.next();
2121-
switch(total_encodings) {
2121+
switch (total_encodings) {
21222122
case 0:
21232123
Assertions.assertEquals("gzip", elt.getName());
21242124
break;

0 commit comments

Comments
 (0)