Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Improve log if VersionedMetaData fails to update

Change-Id: I2c24678dc63c13b523068390474fe16c060559e0
This commit is contained in:
David Pursehouse 2020-01-30 15:05:55 +09:00
commit 5bf069270b

View File

@ -23,6 +23,7 @@ import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.server.logging.TraceContext;
import com.google.gerrit.server.logging.TraceContext.TraceTimer;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
@ -419,14 +420,7 @@ public abstract class VersionedMetaData {
update.fireGitRefUpdatedEvent(ru);
return revision;
case LOCK_FAILURE:
throw new LockFailureException(
"Cannot update "
+ ru.getName()
+ " in "
+ db.getDirectory()
+ ": "
+ ru.getResult(),
ru);
throw new LockFailureException(errorMsg(ru, db.getDirectory()), ru);
case FORCED:
case IO_FAILURE:
case NOT_ATTEMPTED:
@ -437,15 +431,15 @@ public abstract class VersionedMetaData {
case REJECTED_MISSING_OBJECT:
case REJECTED_OTHER_REASON:
default:
throw new IOException(
"Cannot update "
+ ru.getName()
+ " in "
+ db.getDirectory()
+ ": "
+ ru.getResult());
throw new IOException(errorMsg(ru, db.getDirectory()));
}
}
private String errorMsg(RefUpdate ru, File location) {
return String.format(
"Cannot update %s in %s: %s (%s)",
ru.getName(), location, ru.getResult(), ru.getRefLogMessage());
}
};
}