Browse Source

Merge changes I184945ee,Iacaad1a7

* changes:
  Remove unnecessary $NON-NLS comment in BaseReceivePack
  Use try-with-resources to close resources in BaseReceivePack
stable-4.1
Shawn Pearce 10 years ago committed by Gerrit Code Review @ Eclipse.org
parent
commit
5ef9c1709e
  1. 15
      org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

15
org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java

@ -317,7 +317,7 @@ public abstract class BaseReceivePack {
"denynonfastforwards", false); //$NON-NLS-1$ "denynonfastforwards", false); //$NON-NLS-1$
allowOfsDelta = config.getBoolean("repack", "usedeltabaseoffset", //$NON-NLS-1$ //$NON-NLS-2$ allowOfsDelta = config.getBoolean("repack", "usedeltabaseoffset", //$NON-NLS-1$ //$NON-NLS-2$
true); true);
certNonceSeed = config.getString("receive", null, "certnonceseed"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ certNonceSeed = config.getString("receive", null, "certnonceseed"); //$NON-NLS-1$ //$NON-NLS-2$
certNonceSlopLimit = config.getInt("receive", "certnonceslop", 0); //$NON-NLS-1$ //$NON-NLS-2$ certNonceSlopLimit = config.getInt("receive", "certnonceslop", 0); //$NON-NLS-1$ //$NON-NLS-2$
} }
@ -1070,8 +1070,7 @@ public abstract class BaseReceivePack {
if (sideBand) if (sideBand)
resolving = new SideBandProgressMonitor(msgOut); resolving = new SideBandProgressMonitor(msgOut);
ObjectInserter ins = db.newObjectInserter(); try (ObjectInserter ins = db.newObjectInserter()) {
try {
String lockMsg = "jgit receive-pack"; //$NON-NLS-1$ String lockMsg = "jgit receive-pack"; //$NON-NLS-1$
if (getRefLogIdent() != null) if (getRefLogIdent() != null)
lockMsg += " from " + getRefLogIdent().toExternalString(); //$NON-NLS-1$ lockMsg += " from " + getRefLogIdent().toExternalString(); //$NON-NLS-1$
@ -1089,8 +1088,6 @@ public abstract class BaseReceivePack {
packLock = parser.parse(receiving, resolving); packLock = parser.parse(receiving, resolving);
packSize = Long.valueOf(parser.getPackSize()); packSize = Long.valueOf(parser.getPackSize());
ins.flush(); ins.flush();
} finally {
ins.release();
} }
if (timeoutIn != null) if (timeoutIn != null)
@ -1119,7 +1116,7 @@ public abstract class BaseReceivePack {
} }
parser = null; parser = null;
final ObjectWalk ow = new ObjectWalk(db); try (final ObjectWalk ow = new ObjectWalk(db)) {
ow.setRetainBody(false); ow.setRetainBody(false);
if (baseObjects != null) { if (baseObjects != null) {
ow.sort(RevSort.TOPO); ow.sort(RevSort.TOPO);
@ -1147,7 +1144,8 @@ public abstract class BaseReceivePack {
} }
} }
checking.beginTask(JGitText.get().countingObjects, ProgressMonitor.UNKNOWN); checking.beginTask(JGitText.get().countingObjects,
ProgressMonitor.UNKNOWN);
RevCommit c; RevCommit c;
while ((c = ow.next()) != null) { while ((c = ow.next()) != null) {
checking.update(1); checking.update(1);
@ -1183,6 +1181,7 @@ public abstract class BaseReceivePack {
} }
} }
} }
}
/** Validate the command list. */ /** Validate the command list. */
protected void validateCommands() { protected void validateCommands() {
@ -1502,7 +1501,7 @@ public abstract class BaseReceivePack {
* the pack could not be unlocked. * the pack could not be unlocked.
*/ */
protected void release() throws IOException { protected void release() throws IOException {
walk.release(); walk.close();
unlockPack(); unlockPack();
timeoutIn = null; timeoutIn = null;
rawIn = null; rawIn = null;

Loading…
Cancel
Save