Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 06756ba

Browse files
committed
Merge branch 'stable-7.2' into stable-7.3
* stable-7.2: Ensure pack files are closed after git.close() util.Iterators: suppress warning about object arrays util.Iterators: private constructor for utility class Prevent CommitGraphWriter.write() from closing its stream Make CancellableDigestOutputStream extend FilterOutputStream Change-Id: Ifc76978d796c2dc196a2733e2cbbe0cd959cca24
2 parents 97c257a + 576f25b commit 06756ba

File tree

5 files changed

+15
-19
lines changed

5 files changed

+15
-19
lines changed

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/commitgraph/CommitGraphWriter.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ public Stats write(@NonNull ProgressMonitor monitor,
134134
chunks = Collections.unmodifiableList(chunks);
135135

136136
long expectedSize = calculateExpectedSize(chunks);
137-
try (CancellableDigestOutputStream out = new CancellableDigestOutputStream(
138-
monitor, commitGraphStream)) {
137+
try {
138+
CancellableDigestOutputStream out = new CancellableDigestOutputStream(
139+
monitor, commitGraphStream);
139140
writeHeader(out, chunks.size());
140141
writeChunkLookup(out, chunks);
141142
writeChunks(out, chunks);

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -944,13 +944,9 @@ void writeCommitGraph(@NonNull Set<? extends ObjectId> wants)
944944
tmpFile = File.createTempFile("commit_", //$NON-NLS-1$
945945
COMMIT_GRAPH.getTmpExtension(),
946946
repo.getObjectDatabase().getInfoDirectory());
947-
// write the commit-graph file
948-
try (FileOutputStream fos = new FileOutputStream(tmpFile);
949-
FileChannel channel = fos.getChannel();
950-
OutputStream channelStream = Channels
951-
.newOutputStream(channel)) {
952-
writer.write(pm, channelStream);
953-
channel.force(true);
947+
// write the commit-graph to temporary file
948+
try (FileOutputStream fos = new FileOutputStream(tmpFile)) {
949+
writer.write(pm, fos);
954950
}
955951

956952
// rename the temporary file to real file

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/WindowCache.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ else if (eb < 4)
522522
bs = tableSize / 2;
523523
}
524524
removalBlockSize = bs;
525-
numRemovalBlocks = tableSize / removalBlockSize;
525+
numRemovalBlocks = (int) Math
526+
.ceil((double) tableSize / removalBlockSize);
526527
blockBeingRemoved = numRemovalBlocks - 1;
527528

528529
if (maxFiles < 1)

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/io/CancellableDigestOutputStream.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,21 @@
1515

1616
import java.io.IOException;
1717
import java.io.InterruptedIOException;
18+
import java.io.FilterOutputStream;
1819
import java.io.OutputStream;
1920
import java.security.MessageDigest;
2021

2122
/**
2223
* An OutputStream that keeps a digest and checks every N bytes for
2324
* cancellation.
2425
*/
25-
public class CancellableDigestOutputStream extends OutputStream {
26+
public class CancellableDigestOutputStream extends FilterOutputStream {
2627

2728
/** The OutputStream checks every this value for cancellation **/
2829
public static final int BYTES_TO_WRITE_BEFORE_CANCEL_CHECK = 128 * 1024;
2930

3031
private final ProgressMonitor writeMonitor;
3132

32-
private final OutputStream out;
33-
3433
private final MessageDigest md = Constants.newMessageDigest();
3534

3635
private long count;
@@ -47,8 +46,8 @@ public class CancellableDigestOutputStream extends OutputStream {
4746
*/
4847
public CancellableDigestOutputStream(ProgressMonitor writeMonitor,
4948
OutputStream out) {
49+
super(out);
5050
this.writeMonitor = writeMonitor;
51-
this.out = out;
5251
this.checkCancelAt = BYTES_TO_WRITE_BEFORE_CANCEL_CHECK;
5352
}
5453

@@ -113,9 +112,4 @@ public final void write(byte[] b, int off, int len) throws IOException {
113112
len -= n;
114113
}
115114
}
116-
117-
@Override
118-
public void flush() throws IOException {
119-
out.flush();
120-
}
121115
}

org.eclipse.jgit/src/org/eclipse/jgit/util/Iterators.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Iterators {
2424
* @param array T[]
2525
* @return Iterator<T>
2626
*/
27+
@SuppressWarnings("AvoidObjectArrays")
2728
public static <T> Iterator<T> reverseIterator(T[] array) {
2829
return new Iterator<>() {
2930
int index = array.length;
@@ -54,4 +55,7 @@ public Iterator<T> iterator() {
5455
}
5556
};
5657
}
58+
59+
private Iterators() {
60+
}
5761
}

0 commit comments

Comments
 (0)