Merge changes I184945ee,Iacaad1a7

* changes:
  Remove unnecessary $NON-NLS comment in BaseReceivePack
  Use try-with-resources to close resources in BaseReceivePack
This commit is contained in:
Shawn Pearce 2015-04-08 21:04:07 -04:00 committed by Gerrit Code Review @ Eclipse.org
commit 5ef9c1709e
1 changed files with 60 additions and 61 deletions

View File

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