From 4f5afe9d7c2eb5e11140d2cff328782478588c71 Mon Sep 17 00:00:00 2001 From: Ivan Frade Date: Tue, 5 Sep 2023 11:25:54 -0700 Subject: [PATCH] CommitGraphWriter: Make the list of chunks immutable The chunk list is calculated before start writing and it is immutable afterwards. Make this explicit using an unmodifiable list for the chunks. Change-Id: I4a5cfb1f3d06a9393d8d93a3fac3c128cf3faec0 --- .../jgit/internal/storage/commitgraph/CommitGraphWriter.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java index afbd7e654a..aef01fbb3c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java @@ -33,6 +33,7 @@ import java.io.OutputStream; import java.nio.ByteBuffer; import java.text.MessageFormat; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -171,7 +172,7 @@ public class CommitGraphWriter { chunks.add(new ChunkHeader(CHUNK_ID_BLOOM_FILTER_DATA, bloomFilterChunks.data)); } - return chunks; + return Collections.unmodifiableList(chunks); } private static long calculateExpectedSize(List chunks) { -- 2.39.5