Browse Source

Merge branch 'stable-5.12'

* stable-5.12:
  LockFile: create OutputStream only when needed
  Remove ReftableNumbersNotIncreasingException

Change-Id: I9d85187d00771beef908f1136015d059024f4118
tags/v5.12.0.202105261145-m3
Matthias Sohn 3 years ago
parent
commit
cf76a92e04

+ 0
- 37
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileReftableStack.java View File

@@ -131,33 +131,6 @@ public class FileReftableStack implements AutoCloseable {
return stats;
}

/** Thrown if the update indices in the stack are not monotonic */
public static class ReftableNumbersNotIncreasingException
extends RuntimeException {
private static final long serialVersionUID = 1L;

String name;

long lastMax;

long min;

ReftableNumbersNotIncreasingException(String name, long lastMax,
long min) {
this.name = name;
this.lastMax = lastMax;
this.min = min;
}

@SuppressWarnings({ "nls", "boxing" })
@Override
public String toString() {
return String.format(
"ReftableNumbersNotIncreasingException %s: min %d, lastMax %d",
name, min, lastMax);
}
}

/**
* Reloads the stack, potentially reusing opened reftableReaders.
*
@@ -176,7 +149,6 @@ public class FileReftableStack implements AutoCloseable {
List<ReftableReader> newTables = new ArrayList<>();
List<StackEntry> newStack = new ArrayList<>(stack.size() + 1);
try {
ReftableReader last = null;
for (String name : names) {
StackEntry entry = new StackEntry();
entry.name = name;
@@ -194,15 +166,6 @@ public class FileReftableStack implements AutoCloseable {
newTables.add(t);
}

if (last != null) {
// TODO: move this to MergedReftable
if (last.maxUpdateIndex() >= t.minUpdateIndex()) {
throw new ReftableNumbersNotIncreasingException(name,
last.maxUpdateIndex(), t.minUpdateIndex());
}
}
last = t;

entry.reftableReader = t;
newStack.add(entry);
}

+ 12
- 12
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java View File

@@ -218,14 +218,14 @@ public class LockFile {
int r;
while ((r = fis.read(buf)) >= 0) {
out.write(buf, 0, r);
}
}
} catch (FileNotFoundException fnfe) {
if (ref.exists()) {
throw fnfe;
}
// Don't worry about a file that doesn't exist yet, it
// conceptually has no current content to copy.
}
} catch (FileNotFoundException fnfe) {
if (ref.exists()) {
throw fnfe;
}
// Don't worry about a file that doesn't exist yet, it
// conceptually has no current content to copy.
}
} catch (IOException | RuntimeException | Error ioe) {
unlock();
@@ -322,9 +322,9 @@ public class LockFile {
if (out == null) {
os = getStream();
if (fsync) {
out = Channels.newOutputStream(os.getChannel());
out = Channels.newOutputStream(os.getChannel());
} else {
out = os;
out = os;
}
}
return out;
@@ -359,10 +359,10 @@ public class LockFile {
}
if (out != null) {
if (fsync) {
os.getChannel().force(true);
os.getChannel().force(true);
}
out.close();
os = null;
out.close();
os = null;
}
written = true;
} catch (IOException | RuntimeException | Error ioe) {

Loading…
Cancel
Save