commit 887b57b36ae92d89c4cb6804beee6d5c1f29ddc7 Author: Marcin Czech Date: Fri Oct 16 22:01:24 2020 +0200 DelegateRepository must delegate all calls to the delegate DelegateRepository extends Repository class which is a basic repository implementation. Without delegating all calls to the delegate, methods from basic implementation are called. This cause unexpected behaviour. For example even if delegate is an instance of FileRepository call to DelegateRepository.setGitwebDescription calls Repository.setGitwebDescription which throws IOException. Feature: Issue 13429 Change-Id: Ie74d93ee680f6d1db52271fff2c0413479a0209e diff --git a/java/com/google/gerrit/server/git/DelegateRepository.java b/java/com/google/gerrit/server/git/DelegateRepository.java index 9c860c4..2816429 100644 --- a/java/com/google/gerrit/server/git/DelegateRepository.java +++ b/java/com/google/gerrit/server/git/DelegateRepository.java @@ -15,14 +15,40 @@ package com.google.gerrit.server.git; import com.google.gerrit.common.UsedAt; +import java.io.File; import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.Set; import org.eclipse.jgit.attributes.AttributesNodeProvider; +import org.eclipse.jgit.dircache.DirCache; +import org.eclipse.jgit.errors.AmbiguousObjectException; +import org.eclipse.jgit.errors.CorruptObjectException; +import org.eclipse.jgit.errors.IncorrectObjectTypeException; +import org.eclipse.jgit.errors.MissingObjectException; +import org.eclipse.jgit.errors.NoWorkTreeException; +import org.eclipse.jgit.errors.RevisionSyntaxException; +import org.eclipse.jgit.events.ListenerList; +import org.eclipse.jgit.events.RepositoryEvent; +import org.eclipse.jgit.lib.AnyObjectId; import org.eclipse.jgit.lib.BaseRepositoryBuilder; import org.eclipse.jgit.lib.ObjectDatabase; +import org.eclipse.jgit.lib.ObjectId; +import org.eclipse.jgit.lib.ObjectInserter; +import org.eclipse.jgit.lib.ObjectLoader; +import org.eclipse.jgit.lib.ObjectReader; +import org.eclipse.jgit.lib.ProgressMonitor; +import org.eclipse.jgit.lib.RebaseTodoLine; +import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.RefDatabase; +import org.eclipse.jgit.lib.RefRename; +import org.eclipse.jgit.lib.RefUpdate; import org.eclipse.jgit.lib.ReflogReader; import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.lib.StoredConfig; +import org.eclipse.jgit.revwalk.RevCommit; +import org.eclipse.jgit.util.FS; /** Wrapper around {@link Repository} that delegates all calls to the wrapped {@link Repository}. */ @UsedAt(UsedAt.Project.PLUGIN_HIGH_AVAILABILITY) @@ -90,4 +116,279 @@ public class DelegateRepository extends Repository { return new BaseRepositoryBuilder<>().setFS(repo.getFS()).setGitDir(repo.getDirectory()); } + + @Override + public ListenerList getListenerList() { + return delegate.getListenerList(); + } + + @Override + public void fireEvent(RepositoryEvent event) { + delegate.fireEvent(event); + } + + @Override + public void create() throws IOException { + delegate.create(); + } + + @Override + public File getDirectory() { + return delegate.getDirectory(); + } + + @Override + public ObjectInserter newObjectInserter() { + return delegate.newObjectInserter(); + } + + @Override + public ObjectReader newObjectReader() { + return delegate.newObjectReader(); + } + + @Override + public FS getFS() { + return delegate.getFS(); + } + + @Override + @Deprecated + public boolean hasObject(AnyObjectId objectId) { + return delegate.hasObject(objectId); + } + + @Override + public ObjectLoader open(AnyObjectId objectId, int typeHint) + throws MissingObjectException, IncorrectObjectTypeException, IOException { + return delegate.open(objectId, typeHint); + } + + @Override + public void incrementOpen() { + delegate.incrementOpen(); + } + + @Override + public void close() { + delegate.close(); + } + + @Override + public String getFullBranch() throws IOException { + return delegate.getFullBranch(); + } + + @Override + public String getBranch() throws IOException { + return delegate.getBranch(); + } + + @Override + @Deprecated + public Map getAllRefs() { + return delegate.getAllRefs(); + } + + @Override + @Deprecated + public Map getTags() { + return delegate.getTags(); + } + + @Override + public DirCache lockDirCache() throws NoWorkTreeException, CorruptObjectException, IOException { + return delegate.lockDirCache(); + } + + @Override + public void autoGC(ProgressMonitor monitor) { + delegate.autoGC(monitor); + } + + @Override + public Set getAdditionalHaves() { + return delegate.getAdditionalHaves(); + } + + @Override + public Map> getAllRefsByPeeledObjectId() { + return delegate.getAllRefsByPeeledObjectId(); + } + + @Override + public File getIndexFile() throws NoWorkTreeException { + return delegate.getIndexFile(); + } + + @Override + public RepositoryState getRepositoryState() { + return delegate.getRepositoryState(); + } + + @Override + public boolean isBare() { + return delegate.isBare(); + } + + @Override + public File getWorkTree() throws NoWorkTreeException { + return delegate.getWorkTree(); + } + + @Override + public String getRemoteName(String refName) { + return delegate.getRemoteName(refName); + } + + @Override + public String getGitwebDescription() throws IOException { + return delegate.getGitwebDescription(); + } + + @Override + public Set getRemoteNames() { + return delegate.getRemoteNames(); + } + + @Override + public ObjectLoader open(AnyObjectId objectId) throws MissingObjectException, IOException { + return delegate.open(objectId); + } + + @Override + public RefUpdate updateRef(String ref) throws IOException { + return delegate.updateRef(ref); + } + + @Override + public RefUpdate updateRef(String ref, boolean detach) throws IOException { + return delegate.updateRef(ref, detach); + } + + @Override + public RefRename renameRef(String fromRef, String toRef) throws IOException { + return delegate.renameRef(fromRef, toRef); + } + + @Override + public ObjectId resolve(String revstr) + throws AmbiguousObjectException, IncorrectObjectTypeException, RevisionSyntaxException, + IOException { + return delegate.resolve(revstr); + } + + @Override + public String simplify(String revstr) throws AmbiguousObjectException, IOException { + return delegate.simplify(revstr); + } + + @Override + @Deprecated + public Ref peel(Ref ref) { + return delegate.peel(ref); + } + + @Override + public RevCommit parseCommit(AnyObjectId id) + throws IncorrectObjectTypeException, IOException, MissingObjectException { + return delegate.parseCommit(id); + } + + @Override + public DirCache readDirCache() throws NoWorkTreeException, CorruptObjectException, IOException { + return delegate.readDirCache(); + } + + @Override + public String shortenRemoteBranchName(String refName) { + return delegate.shortenRemoteBranchName(refName); + } + + @Override + public void setGitwebDescription(String description) throws IOException { + delegate.setGitwebDescription(description); + } + + @Override + public String readMergeCommitMsg() throws IOException, NoWorkTreeException { + return delegate.readMergeCommitMsg(); + } + + @Override + public void writeMergeCommitMsg(String msg) throws IOException { + delegate.writeMergeCommitMsg(msg); + } + + @Override + public String readCommitEditMsg() throws IOException, NoWorkTreeException { + return delegate.readCommitEditMsg(); + } + + @Override + public void writeCommitEditMsg(String msg) throws IOException { + delegate.writeCommitEditMsg(msg); + } + + @Override + public List readMergeHeads() throws IOException, NoWorkTreeException { + return delegate.readMergeHeads(); + } + + @Override + public void writeMergeHeads(List heads) throws IOException { + delegate.writeMergeHeads(heads); + } + + @Override + public ObjectId readCherryPickHead() throws IOException, NoWorkTreeException { + return delegate.readCherryPickHead(); + } + + @Override + public ObjectId readRevertHead() throws IOException, NoWorkTreeException { + return delegate.readRevertHead(); + } + + @Override + public void writeCherryPickHead(ObjectId head) throws IOException { + delegate.writeCherryPickHead(head); + } + + @Override + public void writeRevertHead(ObjectId head) throws IOException { + delegate.writeRevertHead(head); + } + + @Override + public void writeOrigHead(ObjectId head) throws IOException { + delegate.writeOrigHead(head); + } + + @Override + public ObjectId readOrigHead() throws IOException, NoWorkTreeException { + return delegate.readOrigHead(); + } + + @Override + public String readSquashCommitMsg() throws IOException { + return delegate.readSquashCommitMsg(); + } + + @Override + public void writeSquashCommitMsg(String msg) throws IOException { + delegate.writeSquashCommitMsg(msg); + } + + @Override + public List readRebaseTodo(String path, boolean includeComments) + throws IOException { + return delegate.readRebaseTodo(path, includeComments); + } + + @Override + public void writeRebaseTodoFile(String path, List steps, boolean append) + throws IOException { + delegate.writeRebaseTodoFile(path, steps, append); + } }