PatchSetInserter: Take ChangeControl instead of RefControl
We want to be able to do an ACL check during validate(), which means having a ChangeControl available. All callers either have one at the call site, or are already constructing a RefControl, so they can just as easily construct a ChangeControl instead. The main reason not to do this is to avoid accidentally using that field rather than the control from the ChangeContext which was read in a transaction. Try to avoid this by giving it a non-obvious name and leaving a comment about it. Change-Id: If0684a488e33850ddd18395a9f49bf4a40823fbc
This commit is contained in:
		@@ -68,8 +68,7 @@ import com.google.gerrit.server.index.change.ChangeField;
 | 
			
		||||
import com.google.gerrit.server.index.change.ChangeIndexCollection;
 | 
			
		||||
import com.google.gerrit.server.index.change.ChangeIndexer;
 | 
			
		||||
import com.google.gerrit.server.notedb.ChangeNotes;
 | 
			
		||||
import com.google.gerrit.server.project.ProjectControl;
 | 
			
		||||
import com.google.gerrit.server.project.RefControl;
 | 
			
		||||
import com.google.gerrit.server.project.ChangeControl;
 | 
			
		||||
import com.google.gerrit.server.schema.SchemaCreator;
 | 
			
		||||
import com.google.gerrit.server.util.RequestContext;
 | 
			
		||||
import com.google.gerrit.server.util.ThreadLocalRequestContext;
 | 
			
		||||
@@ -126,7 +125,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
 | 
			
		||||
  @Inject protected InternalChangeQuery internalChangeQuery;
 | 
			
		||||
  @Inject protected ChangeNotes.Factory notesFactory;
 | 
			
		||||
  @Inject protected PatchSetInserter.Factory patchSetFactory;
 | 
			
		||||
  @Inject protected ProjectControl.GenericFactory projectControlFactory;
 | 
			
		||||
  @Inject protected ChangeControl.GenericFactory changeControlFactory;
 | 
			
		||||
  @Inject protected QueryProcessor queryProcessor;
 | 
			
		||||
  @Inject protected SchemaCreator schemaCreator;
 | 
			
		||||
  @Inject protected Sequences seq;
 | 
			
		||||
@@ -1580,8 +1579,7 @@ public abstract class AbstractQueryChangesTest extends GerritServerTests {
 | 
			
		||||
            .message("message")
 | 
			
		||||
            .add("file" + n, "contents " + n)
 | 
			
		||||
            .create());
 | 
			
		||||
    RefControl ctl = projectControlFactory.controlFor(c.getProject(), user)
 | 
			
		||||
        .controlForRef(c.getDest());
 | 
			
		||||
    ChangeControl ctl = changeControlFactory.controlFor(db, c, user);
 | 
			
		||||
 | 
			
		||||
    PatchSetInserter inserter = patchSetFactory.create(
 | 
			
		||||
          ctl, new PatchSet.Id(c.getId(), n), commit)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user