Commit 9a5c8e4
committed
fix(retry): address bala review on PR #1701 review 4248622939
Five concessions from bala's review batch — each verified against
minio-go's contract or the file's own pre-PR conventions:
BaseS3Client.java
- Restore the `protected static final Random RANDOM` field (with its
java.security.SecureRandom + java.util.Random imports) that
60aeaed dropped when switching backoff jitter to
ThreadLocalRandom. Per bala's r3205617158: do not remove
protected/public API surface. The field is part of the public
subclassing contract on BaseS3Client and is the Java analogue of
minio-go's per-client `c.random` source (api.go:307); SDK-internal
code paths still use ThreadLocalRandom.current() for the retry
backoff hot path so jitter is unchanged.
- Drop the null-guard around `regionCache.remove(s3request.bucket())`
introduced in beead6e. The guard was only load-bearing for the
contrived testNoRetryOn404 (listBuckets + 404 NoSuchBucket — a wire
shape no spec-compliant S3 server emits since NoSuchBucket only
applies to bucket-scoped ops); the test is rewritten in this commit
to a realistic scenario, removing the dependency on the guard.
Http.java
- Drop the two-line `// Our RetryInterceptor handles transient
failures with full-jitter backoff; defer entirely to it instead of
layering OkHttp's connection-level retry on top.` comment from
newDefaultClient() per bala's r3205589355: the
retryOnConnectionFailure(false) call paired with addInterceptor(new
RetryInterceptor()) is self-explanatory and the prose duplicated the
RetryInterceptor Javadoc.
- Drop the `Utils.validateNotNull(requestBody, "request body")` guard
from the Body(okhttp3.RequestBody) constructor per bala's
r3205613399; the three other Body constructors do not validate
non-null and let the next-line dereference fail with the JVM's
helpful-NPE message — restoring that local convention.
- Drop the `private long fileOffset` field, its capture in the
Body(RandomAccessFile,...) constructor, and the seek in
toRequestBody() per bala's r3205614300. Empirical truth-table probe
(4 trials toggling F = Body.fileOffset against C+R = createBody
save/restore + RequestBody.position+seek) confirmed F is redundant
when C+R are present: removing F alone keeps both first-attempt and
retry-attempt body content correct (Trial 3), since the
pre-Body-construction seek in createBody already places the file
pointer where RequestBody.position will capture it on construction
and writeTo() will seek back to on each network attempt.
RetryTest.java
- Rewrite testNoRetryOn404 to call removeBucket on a non-existent
bucket. NoSuchBucket only applies to bucket-scoped operations on
the S3 wire; pairing it with the bucket-less listBuckets() is a
contrived scenario AWS S3 / MinIO never produce. The rewrite
preserves coverage (404 does not retry, ErrorResponseException
carries code "NoSuchBucket" and status 404, request count == 1)
while exercising a wire shape the SDK actually has to handle, and
uses a non-null bucket so the regionCache invalidation path runs
with a real ConcurrentHashMap.remove(String) call.
Validated locally on Java 17:
- :api:check (compile + spotless + spotbugs + tests) PASS
- :api:javadoc PASS1 parent 7fe6e87 commit 9a5c8e4
3 files changed
Lines changed: 13 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
| 95 | + | |
93 | 96 | | |
94 | 97 | | |
95 | 98 | | |
| |||
512 | 515 | | |
513 | 516 | | |
514 | 517 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
519 | 521 | | |
520 | 522 | | |
521 | 523 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
626 | | - | |
627 | | - | |
628 | 626 | | |
629 | 627 | | |
630 | 628 | | |
| |||
846 | 844 | | |
847 | 845 | | |
848 | 846 | | |
849 | | - | |
850 | 847 | | |
851 | 848 | | |
852 | 849 | | |
| |||
864 | 861 | | |
865 | 862 | | |
866 | 863 | | |
867 | | - | |
| 864 | + | |
868 | 865 | | |
869 | 866 | | |
870 | 867 | | |
| |||
877 | 874 | | |
878 | 875 | | |
879 | 876 | | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | 877 | | |
886 | 878 | | |
887 | 879 | | |
| |||
955 | 947 | | |
956 | 948 | | |
957 | 949 | | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
| 950 | + | |
966 | 951 | | |
967 | 952 | | |
968 | 953 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
285 | 288 | | |
286 | 289 | | |
287 | 290 | | |
| |||
290 | 293 | | |
291 | 294 | | |
292 | 295 | | |
293 | | - | |
| 296 | + | |
| 297 | + | |
294 | 298 | | |
295 | 299 | | |
296 | 300 | | |
| |||
0 commit comments