Convert remaining uses of MetaDataUpdate to try-with-resource
These were not causing a "should be managed in try-with-resource" warning from Eclipse, and were found by manual inspection. Change-Id: I30c09f329c458117ece5878eeaba9c905eee06b2
This commit is contained in:
@@ -30,12 +30,9 @@ import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
import com.google.gerrit.server.git.ProjectConfig;
|
||||
import com.google.gerrit.server.group.SystemGroupBackend;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
|
||||
private TestAccount user2;
|
||||
@@ -80,20 +77,20 @@ public class ChangeOwnerIT extends AbstractDaemonTest {
|
||||
approve(a, changeId);
|
||||
}
|
||||
|
||||
private void grantApproveToChangeOwner() throws IOException,
|
||||
ConfigInvalidException {
|
||||
MetaDataUpdate md = metaDataUpdateFactory.create(project);
|
||||
md.setMessage(String.format("Grant approve to change owner"));
|
||||
ProjectConfig config = ProjectConfig.read(md);
|
||||
AccessSection s = config.getAccessSection("refs/heads/*", true);
|
||||
Permission p = s.getPermission(LABEL + "Code-Review", true);
|
||||
PermissionRule rule = new PermissionRule(config
|
||||
.resolve(SystemGroupBackend.getGroup(SystemGroupBackend.CHANGE_OWNER)));
|
||||
rule.setMin(-2);
|
||||
rule.setMax(+2);
|
||||
p.add(rule);
|
||||
config.commit(md);
|
||||
projectCache.evict(config.getProject());
|
||||
private void grantApproveToChangeOwner() throws Exception {
|
||||
try (MetaDataUpdate md = metaDataUpdateFactory.create(project)) {
|
||||
md.setMessage(String.format("Grant approve to change owner"));
|
||||
ProjectConfig config = ProjectConfig.read(md);
|
||||
AccessSection s = config.getAccessSection("refs/heads/*", true);
|
||||
Permission p = s.getPermission(LABEL + "Code-Review", true);
|
||||
PermissionRule rule = new PermissionRule(config
|
||||
.resolve(SystemGroupBackend.getGroup(SystemGroupBackend.CHANGE_OWNER)));
|
||||
rule.setMin(-2);
|
||||
rule.setMax(+2);
|
||||
p.add(rule);
|
||||
config.commit(md);
|
||||
projectCache.evict(config.getProject());
|
||||
}
|
||||
}
|
||||
|
||||
private String createMyChange() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user