Skip to content

Commit 41bc358

Browse files
authored
fix: correctly use bytebuffer slice in decodecontexts method
Signed-off-by: Tino Britty <[email protected]>
1 parent 31ee997 commit 41bc358

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/src/main/java/kafka/automq/failover/FailoverListener.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,15 @@ private Optional<FailoverContext[]> getContexts(MetadataDelta delta) {
8080
.map(kv -> kv.get(FailoverConstants.FAILOVER_KEY))
8181
.map(this::decodeContexts);
8282
}
83-
84-
private FailoverContext[] decodeContexts(ByteBuffer byteBuffer) {
85-
byteBuffer.slice();
86-
byte[] data = new byte[byteBuffer.remaining()];
87-
byteBuffer.get(data);
83+
84+
private FailoverContext[] decodeContexts(ByteBuffer byteBuffer) {
85+
ByteBuffer slice = byteBuffer.slice();
86+
byte[] data = new byte[slice.remaining()];
87+
slice.get(data);
8888
return JsonUtils.decode(new String(data, StandardCharsets.UTF_8), FailoverContext[].class);
8989
}
9090

91+
9192
private void onContextsChange(FailoverContext[] contexts) {
9293
Set<FailedNode> oldFailedNodes = recovering.keySet();
9394
Set<FailedNode> newFailedNodes = Arrays.stream(contexts)

0 commit comments

Comments
 (0)