This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git
The following commit(s) were added to refs/heads/main by this push:
new d6f888714 refactor: replace .toArray().length with .size() (Java 11+)
(#1095)
d6f888714 is described below
commit d6f88871454f25c5d5da7b6d4abe44583303eead
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Fri Jun 26 21:06:07 2026 +0800
refactor: replace .toArray().length with .size() (Java 11+) (#1095)
Motivation:
Creating an array just to check its length is unnecessary. List.size()
is more idiomatic and avoids the allocation.
Modification:
Replace bodyParts.toArray().length with bodyParts.size() in
RangeDirectivesExamplesTest.
Result:
Cleaner code, no unnecessary array allocation.
Tests: sbt "docs / Test / compile"
References: https://javaalmanac.io/jdk/17/apidiff/8/
---
.../http/javadsl/server/directives/RangeDirectivesExamplesTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git
a/docs/src/test/java/docs/http/javadsl/server/directives/RangeDirectivesExamplesTest.java
b/docs/src/test/java/docs/http/javadsl/server/directives/RangeDirectivesExamplesTest.java
index 937ef7fd1..f99ccc9a1 100644
---
a/docs/src/test/java/docs/http/javadsl/server/directives/RangeDirectivesExamplesTest.java
+++
b/docs/src/test/java/docs/http/javadsl/server/directives/RangeDirectivesExamplesTest.java
@@ -101,7 +101,7 @@ public class RangeDirectivesExamplesTest extends
JUnitJupiterRouteTest {
try {
final List<Multipart.ByteRanges.BodyPart> bodyParts =
completionStage.toCompletableFuture().get(3, TimeUnit.SECONDS);
- assertEquals(2, bodyParts.toArray().length);
+ assertEquals(2, bodyParts.size());
final Multipart.ByteRanges.BodyPart part1 = bodyParts.get(0);
assertEquals(bytes028Range, part1.getContentRange());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]