Skip to content

Commit ad5d28a

Browse files
committed
+ elf4j version bump
1 parent 4bcbc6d commit ad5d28a

File tree

3 files changed

+38
-34
lines changed

3 files changed

+38
-34
lines changed

pom.xml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<modelVersion>4.0.0</modelVersion>
2929
<groupId>io.github.q3769</groupId>
3030
<artifactId>chunk4j</artifactId>
31-
<version>20250322.0.2025</version>
31+
<version>20250322.0.202505</version>
3232
<packaging>jar</packaging>
3333
<name>chunk4j</name>
3434
<description>A Java API to chop up larger data blobs into smaller "chunks" of a pre-defined size, and stitch the
@@ -144,13 +144,23 @@
144144
<dependency>
145145
<groupId>io.github.elf4j</groupId>
146146
<artifactId>elf4j</artifactId>
147-
<version>4.1.1</version>
147+
<version>4.2.0</version>
148148
</dependency>
149149
<dependency>
150150
<groupId>com.google.code.findbugs</groupId>
151151
<artifactId>jsr305</artifactId>
152152
<version>3.0.2</version>
153153
</dependency>
154+
<dependency>
155+
<groupId>net.jcip</groupId>
156+
<artifactId>jcip-annotations</artifactId>
157+
<version>1.0</version>
158+
</dependency>
159+
<dependency>
160+
<groupId>jakarta.annotation</groupId>
161+
<artifactId>jakarta.annotation-api</artifactId>
162+
<version>3.0.0</version>
163+
</dependency>
154164
<dependency>
155165
<groupId>org.projectlombok</groupId>
156166
<artifactId>lombok</artifactId>
@@ -160,7 +170,7 @@
160170
<dependency>
161171
<groupId>io.github.elf4j</groupId>
162172
<artifactId>elf4j-provider</artifactId>
163-
<version>15.0.0</version>
173+
<version>15.1.0</version>
164174
<scope>test</scope>
165175
</dependency>
166176
<dependency>

src/main/java/chunk4j/ChunkStitcher.java

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
import com.github.benmanes.caffeine.cache.*;
2828
import elf4j.Level;
2929
import elf4j.Logger;
30+
import jakarta.annotation.Nullable;
3031
import java.time.Duration;
3132
import java.util.*;
3233
import java.util.stream.Collectors;
33-
import javax.annotation.Nullable;
3434
import javax.annotation.concurrent.NotThreadSafe;
3535
import javax.annotation.concurrent.ThreadSafe;
3636
import lombok.Data;
@@ -48,7 +48,7 @@ public final class ChunkStitcher implements Stitcher {
4848
private static final int DEFAULT_MAX_STITCHED_BYTE_SIZE = Integer.MAX_VALUE;
4949
private static final long DEFAULT_MAX_STITCHING_GROUPS = Long.MAX_VALUE;
5050
private static final long DEFAULT_MAX_STITCH_TIME_NANOS = Long.MAX_VALUE;
51-
private static final Logger logger = Logger.instance();
51+
private static final Logger log = Logger.instance();
5252
private final Cache<UUID, ChunkStitchingGroup> chunkGroups;
5353
private final Duration maxStitchTime;
5454
private final int maxStitchedByteSize;
@@ -80,8 +80,8 @@ private ChunkStitcher(@NonNull Builder builder) {
8080
* the group, or an empty Optional otherwise.
8181
*/
8282
@Override
83-
public Optional<byte[]> stitch(@NonNull Chunk chunk) {
84-
logger.atTrace().log(() -> "Received: " + chunk);
83+
public @NonNull Optional<byte[]> stitch(@NonNull Chunk chunk) {
84+
log.trace(() -> "Received: " + chunk);
8585
StitchedBytesHolder stitchedBytesHolder = new StitchedBytesHolder();
8686
chunkGroups.asMap().compute(chunk.groupId(), (k, group) -> {
8787
if (group == null) {
@@ -107,13 +107,11 @@ private void checkStitchingGroupByteSize(Chunk chunk, ChunkStitchingGroup group)
107107
return;
108108
}
109109
if (chunk.bytes().length + group.getCurrentGroupByteSize() > maxStitchedByteSize) {
110-
logger
111-
.atWarn()
112-
.log(
113-
"By adding {}, stitching group {} would have exceeded safe-guarding byte size {}",
114-
chunk,
115-
chunk.groupId(),
116-
maxStitchedByteSize);
110+
log.warn(
111+
"By adding {}, stitching group {} would have exceeded safe-guarding byte size {}",
112+
chunk,
113+
chunk.groupId(),
114+
maxStitchedByteSize);
117115
throw new IllegalArgumentException("Stitched bytes in group exceeding configured max size");
118116
}
119117
}
@@ -239,13 +237,13 @@ private static int totalByteSizeOf(@NonNull Collection<Chunk> chunks) {
239237
* @return A byte array containing the stitched chunks if the chunk is the last one expected by
240238
* the group, or null otherwise.
241239
*/
242-
@Nullable public byte[] addAndStitch(Chunk chunk) {
240+
public @Nullable byte[] addAndStitch(Chunk chunk) {
243241
if (!chunks.add(chunk)) {
244-
logger.atWarn().log("Duplicate chunk {} received and ignored", chunk);
242+
log.warn("Duplicate chunk {} received and ignored", chunk);
245243
return null;
246244
}
247245
if (getCurrentChunkTotal() == getExpectedChunkTotal()) {
248-
logger.atDebug().log(() -> "Stitching all " + chunks.size() + " chunks in group " + this);
246+
log.debug(() -> "Stitching all " + chunks.size() + " chunks in group " + this);
249247
return stitchToBytes(chunks);
250248
}
251249
return null;
@@ -328,22 +326,18 @@ public void onRemoval(
328326
UUID groupId, ChunkStitchingGroup chunkStitchingGroup, @NonNull RemovalCause cause) {
329327
switch (cause) {
330328
case EXPIRED ->
331-
logger
332-
.atWarn()
333-
.log(
334-
"chunk group [{}] took too long to stitch and expired after [{}], expecting [{}] chunks but only received [{}] when expired",
335-
groupId,
336-
maxStitchTime,
337-
chunkStitchingGroup.getExpectedChunkTotal(),
338-
chunkStitchingGroup.getCurrentChunkTotal());
329+
log.warn(
330+
"chunk group [{}] took too long to stitch and expired after [{}], expecting [{}] chunks but only received [{}] when expired",
331+
groupId,
332+
maxStitchTime,
333+
chunkStitchingGroup.getExpectedChunkTotal(),
334+
chunkStitchingGroup.getCurrentChunkTotal());
339335
case SIZE ->
340-
logger
341-
.atWarn()
342-
.log(
343-
"chunk group [{}] was removed due to exceeding max group count [{}]",
344-
groupId,
345-
maxStitchingGroups);
346-
default -> logger.atLevel(Level.OFF).log("Manual removals logging is OFF");
336+
log.warn(
337+
"chunk group [{}] was removed due to exceeding max group count [{}]",
338+
groupId,
339+
maxStitchingGroups);
340+
default -> log.atLevel(Level.OFF).log("Manual removals logging is OFF");
347341
}
348342
}
349343
}

src/test/java/chunk4j/ChunkStitcherTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ void lessThanNeeded() throws InterruptedException, ExecutionException {
7171

7272
long allStitchedItems =
7373
allStitchedOptionals.stream().filter(Optional::isPresent).count();
74-
log.atInfo().log("Original data items: {}", originalDataItems);
75-
log.atInfo().log("Stitched data items: {}", allStitchedItems);
74+
log.info("Original data items: {}", originalDataItems);
75+
log.info("Stitched data items: {}", allStitchedItems);
7676
assertTrue(
7777
allStitchedItems < originalDataItems,
7878
"stitched and restored items [" + allStitchedItems

0 commit comments

Comments
 (0)