Prefer requireNonNull from Java API over Guava's checkNotNull
Most replacements are a trivial one-to-one replacement of the call to checkNotNull with requireNonNull, however there are some calls that make use of checkNotNull's variable argument list and formatting parameters. Replace these with String.format wrapped in a supplier. Using the Java API rather than Guava means we can get rid of the custom implementation, and Edwin's TODO, in AccessSection. Change-Id: I1d4a6b342e3544abdbba4f05ac4308d223b6768b
This commit is contained in:
parent
d01e5b2312
commit
e1e0ae5157
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.acceptance;
|
package com.google.gerrit.acceptance;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@ -144,7 +144,8 @@ public class AccountCreator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TestAccount get(String username) {
|
public TestAccount get(String username) {
|
||||||
return checkNotNull(accounts.get(username), "No TestAccount created for %s", username);
|
return requireNonNull(
|
||||||
|
accounts.get(username), () -> String.format("No TestAccount created for %s ", username));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void evict(Collection<Account.Id> ids) {
|
public void evict(Collection<Account.Id> ids) {
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
package com.google.gerrit.acceptance;
|
package com.google.gerrit.acceptance;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.apache.log4j.Logger.getLogger;
|
import static org.apache.log4j.Logger.getLogger;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
@ -411,7 +411,7 @@ public class GerritServer implements AutoCloseable {
|
|||||||
CyclicBarrier serverStarted,
|
CyclicBarrier serverStarted,
|
||||||
String[] additionalArgs)
|
String[] additionalArgs)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
checkNotNull(site);
|
requireNonNull(site);
|
||||||
ExecutorService daemonService = Executors.newSingleThreadExecutor();
|
ExecutorService daemonService = Executors.newSingleThreadExecutor();
|
||||||
String[] args =
|
String[] args =
|
||||||
Stream.concat(
|
Stream.concat(
|
||||||
@ -535,10 +535,10 @@ public class GerritServer implements AutoCloseable {
|
|||||||
Injector testInjector,
|
Injector testInjector,
|
||||||
Daemon daemon,
|
Daemon daemon,
|
||||||
@Nullable ExecutorService daemonService) {
|
@Nullable ExecutorService daemonService) {
|
||||||
this.desc = checkNotNull(desc);
|
this.desc = requireNonNull(desc);
|
||||||
this.sitePath = sitePath;
|
this.sitePath = sitePath;
|
||||||
this.testInjector = checkNotNull(testInjector);
|
this.testInjector = requireNonNull(testInjector);
|
||||||
this.daemon = checkNotNull(daemon);
|
this.daemon = requireNonNull(daemon);
|
||||||
this.daemonService = daemonService;
|
this.daemonService = daemonService;
|
||||||
|
|
||||||
Config cfg = testInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
|
Config cfg = testInjector.getInstance(Key.get(Config.class, GerritServerConfig.class));
|
||||||
|
@ -16,8 +16,8 @@ package com.google.gerrit.acceptance;
|
|||||||
|
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -72,13 +72,13 @@ public class HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasContent() {
|
public boolean hasContent() {
|
||||||
Preconditions.checkNotNull(response, "Response is not initialized.");
|
requireNonNull(response, "Response is not initialized.");
|
||||||
return response.getEntity() != null;
|
return response.getEntity() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getEntityContent() throws IOException {
|
public String getEntityContent() throws IOException {
|
||||||
Preconditions.checkNotNull(response, "Response is not initialized.");
|
requireNonNull(response, "Response is not initialized.");
|
||||||
Preconditions.checkNotNull(response.getEntity(), "Response.Entity is not initialized.");
|
requireNonNull(response.getEntity(), "Response.Entity is not initialized.");
|
||||||
ByteBuffer buf = IO.readWholeStream(response.getEntity().getContent(), 1024);
|
ByteBuffer buf = IO.readWholeStream(response.getEntity().getContent(), 1024);
|
||||||
return RawParseUtils.decode(buf.array(), buf.arrayOffset(), buf.limit()).trim();
|
return RawParseUtils.decode(buf.array(), buf.arrayOffset(), buf.limit()).trim();
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
package com.google.gerrit.acceptance;
|
package com.google.gerrit.acceptance;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.net.HttpHeaders;
|
import com.google.common.net.HttpHeaders;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.extensions.restapi.RawInput;
|
import com.google.gerrit.extensions.restapi.RawInput;
|
||||||
@ -81,7 +81,7 @@ public class RestSession extends HttpSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RestResponse putRaw(String endPoint, RawInput stream) throws IOException {
|
public RestResponse putRaw(String endPoint, RawInput stream) throws IOException {
|
||||||
Preconditions.checkNotNull(stream);
|
requireNonNull(stream);
|
||||||
Request put = Request.Put(getUrl(endPoint));
|
Request put = Request.Put(getUrl(endPoint));
|
||||||
put.addHeader(new BasicHeader("Content-Type", stream.getContentType()));
|
put.addHeader(new BasicHeader("Content-Type", stream.getContentType()));
|
||||||
put.body(
|
put.body(
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.common;
|
package com.google.gerrit.common;
|
||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.annotations.GwtIncompatible;
|
import com.google.common.annotations.GwtIncompatible;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
@ -31,7 +32,7 @@ public class RawInputUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static RawInput create(byte[] bytes, String contentType) {
|
public static RawInput create(byte[] bytes, String contentType) {
|
||||||
Preconditions.checkNotNull(bytes);
|
requireNonNull(bytes);
|
||||||
Preconditions.checkArgument(bytes.length > 0);
|
Preconditions.checkArgument(bytes.length > 0);
|
||||||
return new RawInput() {
|
return new RawInput() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.common.data;
|
package com.google.gerrit.common.data;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -43,7 +45,7 @@ public class AccessSection extends RefConfigSection implements Comparable<Access
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPermissions(List<Permission> list) {
|
public void setPermissions(List<Permission> list) {
|
||||||
checkNotNull(list);
|
requireNonNull(list);
|
||||||
|
|
||||||
Set<String> names = new HashSet<>();
|
Set<String> names = new HashSet<>();
|
||||||
for (Permission p : list) {
|
for (Permission p : list) {
|
||||||
@ -62,7 +64,7 @@ public class AccessSection extends RefConfigSection implements Comparable<Access
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Permission getPermission(String name, boolean create) {
|
public Permission getPermission(String name, boolean create) {
|
||||||
checkNotNull(name);
|
requireNonNull(name);
|
||||||
|
|
||||||
if (permissions != null) {
|
if (permissions != null) {
|
||||||
for (Permission p : permissions) {
|
for (Permission p : permissions) {
|
||||||
@ -86,7 +88,7 @@ public class AccessSection extends RefConfigSection implements Comparable<Access
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addPermission(Permission permission) {
|
public void addPermission(Permission permission) {
|
||||||
checkNotNull(permission);
|
requireNonNull(permission);
|
||||||
|
|
||||||
if (permissions == null) {
|
if (permissions == null) {
|
||||||
permissions = new ArrayList<>();
|
permissions = new ArrayList<>();
|
||||||
@ -102,12 +104,12 @@ public class AccessSection extends RefConfigSection implements Comparable<Access
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void remove(Permission permission) {
|
public void remove(Permission permission) {
|
||||||
checkNotNull(permission);
|
requireNonNull(permission);
|
||||||
removePermission(permission.getName());
|
removePermission(permission.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePermission(String name) {
|
public void removePermission(String name) {
|
||||||
checkNotNull(name);
|
requireNonNull(name);
|
||||||
|
|
||||||
if (permissions != null) {
|
if (permissions != null) {
|
||||||
permissions.removeIf(permission -> name.equalsIgnoreCase(permission.getName()));
|
permissions.removeIf(permission -> name.equalsIgnoreCase(permission.getName()));
|
||||||
@ -115,7 +117,7 @@ public class AccessSection extends RefConfigSection implements Comparable<Access
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void mergeFrom(AccessSection section) {
|
public void mergeFrom(AccessSection section) {
|
||||||
checkNotNull(section);
|
requireNonNull(section);
|
||||||
|
|
||||||
for (Permission src : section.getPermissions()) {
|
for (Permission src : section.getPermissions()) {
|
||||||
Permission dst = getPermission(src.getName());
|
Permission dst = getPermission(src.getName());
|
||||||
@ -127,13 +129,6 @@ public class AccessSection extends RefConfigSection implements Comparable<Access
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(ekempin): Once the GWT UI is gone use com.google.common.base.Preconditions.checkNotNull
|
|
||||||
private static void checkNotNull(Object reference) {
|
|
||||||
if (reference == null) {
|
|
||||||
throw new NullPointerException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(AccessSection o) {
|
public int compareTo(AccessSection o) {
|
||||||
return comparePattern().compareTo(o.comparePattern());
|
return comparePattern().compareTo(o.comparePattern());
|
||||||
|
@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
package com.google.gerrit.elasticsearch;
|
package com.google.gerrit.elasticsearch;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.CHANGE_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.CHANGE_CODEC;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.PATCH_SET_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.PATCH_SET_CODEC;
|
||||||
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.CLOSED_STATUSES;
|
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.CLOSED_STATUSES;
|
||||||
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.OPEN_STATUSES;
|
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.OPEN_STATUSES;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.apache.commons.codec.binary.Base64.decodeBase64;
|
import static org.apache.commons.codec.binary.Base64.decodeBase64;
|
||||||
|
|
||||||
import com.google.common.collect.FluentIterable;
|
import com.google.common.collect.FluentIterable;
|
||||||
@ -218,7 +218,7 @@ class ElasticChangeIndex extends AbstractElasticIndex<Change.Id, ChangeData>
|
|||||||
if (c == null) {
|
if (c == null) {
|
||||||
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
|
int id = source.get(ChangeField.LEGACY_ID.getName()).getAsInt();
|
||||||
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
// IndexUtils#changeFields ensures either CHANGE or PROJECT is always present.
|
||||||
String projectName = checkNotNull(source.get(ChangeField.PROJECT.getName()).getAsString());
|
String projectName = requireNonNull(source.get(ChangeField.PROJECT.getName()).getAsString());
|
||||||
return changeDataFactory.create(
|
return changeDataFactory.create(
|
||||||
db.get(), new Project.NameKey(projectName), new Change.Id(id));
|
db.get(), new Project.NameKey(projectName), new Change.Id(id));
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.extensions.api.access;
|
package com.google.gerrit.extensions.api.access;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
@ -29,8 +29,8 @@ public class PluginPermission implements GlobalOrPluginPermission {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PluginPermission(String pluginName, String capability, boolean fallBackToAdmin) {
|
public PluginPermission(String pluginName, String capability, boolean fallBackToAdmin) {
|
||||||
this.pluginName = checkNotNull(pluginName, "pluginName");
|
this.pluginName = requireNonNull(pluginName, "pluginName");
|
||||||
this.capability = checkNotNull(capability, "capability");
|
this.capability = requireNonNull(capability, "capability");
|
||||||
this.fallBackToAdmin = fallBackToAdmin;
|
this.fallBackToAdmin = fallBackToAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.extensions.auth.oauth;
|
package com.google.gerrit.extensions.auth.oauth;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
@ -55,9 +55,9 @@ public class OAuthToken implements Serializable {
|
|||||||
|
|
||||||
public OAuthToken(
|
public OAuthToken(
|
||||||
String token, String secret, String raw, long expiresAt, @Nullable String providerId) {
|
String token, String secret, String raw, long expiresAt, @Nullable String providerId) {
|
||||||
this.token = checkNotNull(token, "token");
|
this.token = requireNonNull(token, "token");
|
||||||
this.secret = checkNotNull(secret, "secret");
|
this.secret = requireNonNull(secret, "secret");
|
||||||
this.raw = checkNotNull(raw, "raw");
|
this.raw = requireNonNull(raw, "raw");
|
||||||
this.expiresAt = expiresAt;
|
this.expiresAt = expiresAt;
|
||||||
this.providerId = Strings.emptyToNull(providerId);
|
this.providerId = Strings.emptyToNull(providerId);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.extensions.registration;
|
package com.google.gerrit.extensions.registration;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.annotations.Export;
|
import com.google.gerrit.extensions.annotations.Export;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
@ -33,7 +33,7 @@ public class PrivateInternals_DynamicMapImpl<T> extends DynamicMap<T> {
|
|||||||
* @return handle to remove the item at a later point in time.
|
* @return handle to remove the item at a later point in time.
|
||||||
*/
|
*/
|
||||||
public RegistrationHandle put(String pluginName, String exportName, Provider<T> item) {
|
public RegistrationHandle put(String pluginName, String exportName, Provider<T> item) {
|
||||||
checkNotNull(item);
|
requireNonNull(item);
|
||||||
final NamePair key = new NamePair(pluginName, exportName);
|
final NamePair key = new NamePair(pluginName, exportName);
|
||||||
items.put(key, item);
|
items.put(key, item);
|
||||||
return new RegistrationHandle() {
|
return new RegistrationHandle() {
|
||||||
@ -56,7 +56,7 @@ public class PrivateInternals_DynamicMapImpl<T> extends DynamicMap<T> {
|
|||||||
* the collection.
|
* the collection.
|
||||||
*/
|
*/
|
||||||
public ReloadableRegistrationHandle<T> put(String pluginName, Key<T> key, Provider<T> item) {
|
public ReloadableRegistrationHandle<T> put(String pluginName, Key<T> key, Provider<T> item) {
|
||||||
checkNotNull(item);
|
requireNonNull(item);
|
||||||
String exportName = ((Export) key.getAnnotation()).value();
|
String exportName = ((Export) key.getAnnotation()).value();
|
||||||
NamePair np = new NamePair(pluginName, exportName);
|
NamePair np = new NamePair(pluginName, exportName);
|
||||||
items.put(np, item);
|
items.put(np, item);
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.raw;
|
package com.google.gerrit.httpd.raw;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
|
import static com.google.common.net.HttpHeaders.CONTENT_ENCODING;
|
||||||
import static com.google.common.net.HttpHeaders.ETAG;
|
import static com.google.common.net.HttpHeaders.ETAG;
|
||||||
import static com.google.common.net.HttpHeaders.IF_MODIFIED_SINCE;
|
import static com.google.common.net.HttpHeaders.IF_MODIFIED_SINCE;
|
||||||
import static com.google.common.net.HttpHeaders.IF_NONE_MATCH;
|
import static com.google.common.net.HttpHeaders.IF_NONE_MATCH;
|
||||||
import static com.google.common.net.HttpHeaders.LAST_MODIFIED;
|
import static com.google.common.net.HttpHeaders.LAST_MODIFIED;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.concurrent.TimeUnit.DAYS;
|
import static java.util.concurrent.TimeUnit.DAYS;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
import static javax.servlet.http.HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
|
||||||
@ -111,7 +111,7 @@ public abstract class ResourceServlet extends HttpServlet {
|
|||||||
boolean refresh,
|
boolean refresh,
|
||||||
boolean cacheOnClient,
|
boolean cacheOnClient,
|
||||||
int cacheFileSizeLimitBytes) {
|
int cacheFileSizeLimitBytes) {
|
||||||
this.cache = checkNotNull(cache, "cache");
|
this.cache = requireNonNull(cache, "cache");
|
||||||
this.refresh = refresh;
|
this.refresh = refresh;
|
||||||
this.cacheOnClient = cacheOnClient;
|
this.cacheOnClient = cacheOnClient;
|
||||||
this.cacheFileSizeLimitBytes = cacheFileSizeLimitBytes;
|
this.cacheFileSizeLimitBytes = cacheFileSizeLimitBytes;
|
||||||
@ -308,9 +308,9 @@ public abstract class ResourceServlet extends HttpServlet {
|
|||||||
final byte[] raw;
|
final byte[] raw;
|
||||||
|
|
||||||
Resource(FileTime lastModified, String contentType, byte[] raw) {
|
Resource(FileTime lastModified, String contentType, byte[] raw) {
|
||||||
this.lastModified = checkNotNull(lastModified, "lastModified");
|
this.lastModified = requireNonNull(lastModified, "lastModified");
|
||||||
this.contentType = checkNotNull(contentType, "contentType");
|
this.contentType = requireNonNull(contentType, "contentType");
|
||||||
this.raw = checkNotNull(raw, "raw");
|
this.raw = requireNonNull(raw, "raw");
|
||||||
this.etag = Hashing.murmur3_128().hashBytes(raw).toString();
|
this.etag = Hashing.murmur3_128().hashBytes(raw).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
package com.google.gerrit.httpd.restapi;
|
package com.google.gerrit.httpd.restapi;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.flogger.LazyArgs.lazy;
|
import static com.google.common.flogger.LazyArgs.lazy;
|
||||||
import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS;
|
import static com.google.common.net.HttpHeaders.ACCESS_CONTROL_ALLOW_CREDENTIALS;
|
||||||
@ -33,6 +32,7 @@ import static com.google.common.net.HttpHeaders.VARY;
|
|||||||
import static java.math.RoundingMode.CEILING;
|
import static java.math.RoundingMode.CEILING;
|
||||||
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
|
import static javax.servlet.http.HttpServletResponse.SC_ACCEPTED;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||||
@ -268,7 +268,7 @@ public class RestApiServlet extends HttpServlet {
|
|||||||
Provider<? extends RestCollection<? extends RestResource, ? extends RestResource>> members) {
|
Provider<? extends RestCollection<? extends RestResource, ? extends RestResource>> members) {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Provider<RestCollection<RestResource, RestResource>> n =
|
Provider<RestCollection<RestResource, RestResource>> n =
|
||||||
(Provider<RestCollection<RestResource, RestResource>>) checkNotNull((Object) members);
|
(Provider<RestCollection<RestResource, RestResource>>) requireNonNull((Object) members);
|
||||||
this.globals = globals;
|
this.globals = globals;
|
||||||
this.members = n;
|
this.members = n;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.rpc.project;
|
package com.google.gerrit.httpd.rpc.project;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.common.ProjectAccessUtil.mergeSections;
|
import static com.google.gerrit.common.ProjectAccessUtil.mergeSections;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.gerrit.common.data.AccessSection;
|
import com.google.gerrit.common.data.AccessSection;
|
||||||
@ -235,7 +235,7 @@ public abstract class ProjectAccessHandler<T> extends Handler<T> {
|
|||||||
|
|
||||||
/** Provide a local cache for {@code ProjectPermission.WRITE_CONFIG} capability. */
|
/** Provide a local cache for {@code ProjectPermission.WRITE_CONFIG} capability. */
|
||||||
private boolean canWriteConfig() throws PermissionBackendException {
|
private boolean canWriteConfig() throws PermissionBackendException {
|
||||||
checkNotNull(user);
|
requireNonNull(user);
|
||||||
|
|
||||||
if (canWriteConfig != null) {
|
if (canWriteConfig != null) {
|
||||||
return canWriteConfig;
|
return canWriteConfig;
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package com.google.gerrit.index;
|
package com.google.gerrit.index;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.CharMatcher;
|
import com.google.common.base.CharMatcher;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
@ -69,8 +69,8 @@ public final class FieldDef<I, T> {
|
|||||||
private boolean stored;
|
private boolean stored;
|
||||||
|
|
||||||
public Builder(FieldType<T> type, String name) {
|
public Builder(FieldType<T> type, String name) {
|
||||||
this.type = checkNotNull(type);
|
this.type = requireNonNull(type);
|
||||||
this.name = checkNotNull(name);
|
this.name = requireNonNull(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<T> stored() {
|
public Builder<T> stored() {
|
||||||
@ -99,10 +99,10 @@ public final class FieldDef<I, T> {
|
|||||||
!(repeatable && type == FieldType.INTEGER_RANGE),
|
!(repeatable && type == FieldType.INTEGER_RANGE),
|
||||||
"Range queries against repeated fields are unsupported");
|
"Range queries against repeated fields are unsupported");
|
||||||
this.name = checkName(name);
|
this.name = checkName(name);
|
||||||
this.type = checkNotNull(type);
|
this.type = requireNonNull(type);
|
||||||
this.stored = stored;
|
this.stored = stored;
|
||||||
this.repeatable = repeatable;
|
this.repeatable = repeatable;
|
||||||
this.getter = checkNotNull(getter);
|
this.getter = requireNonNull(getter);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String checkName(String name) {
|
private static String checkName(String name) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package com.google.gerrit.index;
|
package com.google.gerrit.index;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSortedMap;
|
import com.google.common.collect.ImmutableSortedMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@ -34,7 +34,7 @@ public abstract class SchemaDefinitions<V> {
|
|||||||
private final ImmutableSortedMap<Integer, Schema<V>> schemas;
|
private final ImmutableSortedMap<Integer, Schema<V>> schemas;
|
||||||
|
|
||||||
protected SchemaDefinitions(String name, Class<V> valueClass) {
|
protected SchemaDefinitions(String name, Class<V> valueClass) {
|
||||||
this.name = checkNotNull(name);
|
this.name = requireNonNull(name);
|
||||||
this.schemas = SchemaUtil.schemasFromClass(getClass(), valueClass);
|
this.schemas = SchemaUtil.schemasFromClass(getClass(), valueClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.index;
|
package com.google.gerrit.index;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
@ -73,11 +73,11 @@ public abstract class SiteIndexer<K, V, I extends Index<K, V>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setProgressOut(OutputStream out) {
|
public void setProgressOut(OutputStream out) {
|
||||||
progressOut = checkNotNull(out);
|
progressOut = requireNonNull(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVerboseOut(OutputStream out) {
|
public void setVerboseOut(OutputStream out) {
|
||||||
verboseWriter = newPrintWriter(checkNotNull(out));
|
verboseWriter = newPrintWriter(requireNonNull(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Result indexAll(I index);
|
public abstract Result indexAll(I index);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.index.project;
|
package com.google.gerrit.index.project;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.index.IndexRewriter;
|
import com.google.gerrit.index.IndexRewriter;
|
||||||
import com.google.gerrit.index.QueryOptions;
|
import com.google.gerrit.index.QueryOptions;
|
||||||
@ -36,7 +36,7 @@ public class ProjectIndexRewriter implements IndexRewriter<ProjectData> {
|
|||||||
public Predicate<ProjectData> rewrite(Predicate<ProjectData> in, QueryOptions opts)
|
public Predicate<ProjectData> rewrite(Predicate<ProjectData> in, QueryOptions opts)
|
||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
ProjectIndex index = indexes.getSearchIndex();
|
ProjectIndex index = indexes.getSearchIndex();
|
||||||
checkNotNull(index, "no active search index configured for projects");
|
requireNonNull(index, "no active search index configured for projects");
|
||||||
return new IndexedProjectQuery(index, in, opts);
|
return new IndexedProjectQuery(index, in, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.lucene;
|
package com.google.gerrit.lucene;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.lucene.AbstractLuceneIndex.sortFieldName;
|
import static com.google.gerrit.lucene.AbstractLuceneIndex.sortFieldName;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.CHANGE_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.CHANGE_CODEC;
|
||||||
@ -24,6 +23,7 @@ import static com.google.gerrit.server.index.change.ChangeField.LEGACY_ID;
|
|||||||
import static com.google.gerrit.server.index.change.ChangeField.PROJECT;
|
import static com.google.gerrit.server.index.change.ChangeField.PROJECT;
|
||||||
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.CLOSED_STATUSES;
|
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.CLOSED_STATUSES;
|
||||||
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.OPEN_STATUSES;
|
import static com.google.gerrit.server.index.change.ChangeIndexRewriter.OPEN_STATUSES;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
@ -281,7 +281,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
this.indexes = indexes;
|
this.indexes = indexes;
|
||||||
this.predicate = predicate;
|
this.predicate = predicate;
|
||||||
this.query = checkNotNull(queryBuilder.toQuery(predicate), "null query from Lucene");
|
this.query = requireNonNull(queryBuilder.toQuery(predicate), "null query from Lucene");
|
||||||
this.opts = opts;
|
this.opts = opts;
|
||||||
this.sort = sort;
|
this.sort = sort;
|
||||||
this.rawDocumentMapper = rawDocumentMapper;
|
this.rawDocumentMapper = rawDocumentMapper;
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.pgm;
|
package com.google.gerrit.pgm;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
|
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
@ -500,7 +500,7 @@ public class Daemon extends SiteProgram {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean migrateToNoteDb() {
|
private boolean migrateToNoteDb() {
|
||||||
return migrateToNoteDb || NoteDbMigrator.getAutoMigrate(checkNotNull(config));
|
return migrateToNoteDb || NoteDbMigrator.getAutoMigrate(requireNonNull(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Module createIndexModule() {
|
private Module createIndexModule() {
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.pgm;
|
package com.google.gerrit.pgm;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.server.schema.DataSourceProvider.Context.SINGLE_USER;
|
import static com.google.gerrit.server.schema.DataSourceProvider.Context.SINGLE_USER;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@ -101,11 +101,9 @@ public class ProtobufImport extends SiteProgram {
|
|||||||
Map.Entry<Integer, UnknownFieldSet.Field> e =
|
Map.Entry<Integer, UnknownFieldSet.Field> e =
|
||||||
Iterables.getOnlyElement(msg.asMap().entrySet());
|
Iterables.getOnlyElement(msg.asMap().entrySet());
|
||||||
Relation rel =
|
Relation rel =
|
||||||
checkNotNull(
|
requireNonNull(
|
||||||
relations.get(e.getKey()),
|
relations.get(e.getKey()),
|
||||||
"unknown relation ID %s in message: %s",
|
String.format("unknown relation ID %s in message: %s", e.getKey(), msg));
|
||||||
e.getKey(),
|
|
||||||
msg);
|
|
||||||
List<ByteString> values = e.getValue().getLengthDelimitedList();
|
List<ByteString> values = e.getValue().getLengthDelimitedList();
|
||||||
checkState(values.size() == 1, "expected one string field in message: %s", msg);
|
checkState(values.size() == 1, "expected one string field in message: %s", msg);
|
||||||
upsert(rel, values.get(0));
|
upsert(rel, values.get(0));
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.pgm;
|
package com.google.gerrit.pgm;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
|
import static com.google.gerrit.server.schema.DataSourceProvider.Context.MULTI_USER;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@ -132,7 +132,7 @@ public class Reindex extends SiteProgram {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkNotNull(indexDefs, "Called this method before injectMembers?");
|
requireNonNull(indexDefs, "Called this method before injectMembers?");
|
||||||
Set<String> valid = indexDefs.stream().map(IndexDefinition::getName).sorted().collect(toSet());
|
Set<String> valid = indexDefs.stream().map(IndexDefinition::getName).sorted().collect(toSet());
|
||||||
Set<String> invalid = Sets.difference(Sets.newHashSet(indices), valid);
|
Set<String> invalid = Sets.difference(Sets.newHashSet(indices), valid);
|
||||||
if (invalid.isEmpty()) {
|
if (invalid.isEmpty()) {
|
||||||
@ -192,7 +192,8 @@ public class Reindex extends SiteProgram {
|
|||||||
private <K, V, I extends Index<K, V>> boolean reindex(IndexDefinition<K, V, I> def)
|
private <K, V, I extends Index<K, V>> boolean reindex(IndexDefinition<K, V, I> def)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
I index = def.getIndexCollection().getSearchIndex();
|
I index = def.getIndexCollection().getSearchIndex();
|
||||||
checkNotNull(index, "no active search index configured for %s", def.getName());
|
requireNonNull(
|
||||||
|
index, () -> String.format("no active search index configured for %s", def.getName()));
|
||||||
index.markReady(false);
|
index.markReady(false);
|
||||||
index.deleteAll();
|
index.deleteAll();
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.reviewdb.server;
|
package com.google.gerrit.reviewdb.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
@ -49,7 +49,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
private boolean inTransaction;
|
private boolean inTransaction;
|
||||||
|
|
||||||
protected ReviewDbWrapper(ReviewDb delegate) {
|
protected ReviewDbWrapper(ReviewDb delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReviewDb unsafeGetDelegate() {
|
public ReviewDb unsafeGetDelegate() {
|
||||||
@ -161,7 +161,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final ChangeAccess delegate;
|
protected final ChangeAccess delegate;
|
||||||
|
|
||||||
protected ChangeAccessWrapper(ChangeAccess delegate) {
|
protected ChangeAccessWrapper(ChangeAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -687,7 +687,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final AccountGroupAccess delegate;
|
protected final AccountGroupAccess delegate;
|
||||||
|
|
||||||
protected AccountGroupAccessWrapper(AccountGroupAccess delegate) {
|
protected AccountGroupAccessWrapper(AccountGroupAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -783,7 +783,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final AccountGroupNameAccess delegate;
|
protected final AccountGroupNameAccess delegate;
|
||||||
|
|
||||||
protected AccountGroupNameAccessWrapper(AccountGroupNameAccess delegate) {
|
protected AccountGroupNameAccessWrapper(AccountGroupNameAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -875,7 +875,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final AccountGroupMemberAccess delegate;
|
protected final AccountGroupMemberAccess delegate;
|
||||||
|
|
||||||
protected AccountGroupMemberAccessWrapper(AccountGroupMemberAccess delegate) {
|
protected AccountGroupMemberAccessWrapper(AccountGroupMemberAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -973,7 +973,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final AccountGroupMemberAuditAccess delegate;
|
protected final AccountGroupMemberAuditAccess delegate;
|
||||||
|
|
||||||
protected AccountGroupMemberAuditAccessWrapper(AccountGroupMemberAuditAccess delegate) {
|
protected AccountGroupMemberAuditAccessWrapper(AccountGroupMemberAuditAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1073,7 +1073,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final AccountGroupByIdAccess delegate;
|
protected final AccountGroupByIdAccess delegate;
|
||||||
|
|
||||||
protected AccountGroupByIdAccessWrapper(AccountGroupByIdAccess delegate) {
|
protected AccountGroupByIdAccessWrapper(AccountGroupByIdAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1175,7 +1175,7 @@ public class ReviewDbWrapper implements ReviewDb {
|
|||||||
protected final AccountGroupByIdAudAccess delegate;
|
protected final AccountGroupByIdAudAccess delegate;
|
||||||
|
|
||||||
protected AccountGroupByIdAudAccessWrapper(AccountGroupByIdAudAccess delegate) {
|
protected AccountGroupByIdAudAccessWrapper(AccountGroupByIdAudAccess delegate) {
|
||||||
this.delegate = checkNotNull(delegate);
|
this.delegate = requireNonNull(delegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.HashBasedTable;
|
import com.google.common.collect.HashBasedTable;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
@ -152,12 +152,12 @@ public class ApprovalCopier {
|
|||||||
@Nullable Config repoConfig,
|
@Nullable Config repoConfig,
|
||||||
Iterable<PatchSetApproval> dontCopy)
|
Iterable<PatchSetApproval> dontCopy)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
checkNotNull(ps, "ps should not be null");
|
requireNonNull(ps, "ps should not be null");
|
||||||
ChangeData cd = changeDataFactory.create(db, notes);
|
ChangeData cd = changeDataFactory.create(db, notes);
|
||||||
try {
|
try {
|
||||||
ProjectState project = projectCache.checkedGet(cd.change().getDest().getParentKey());
|
ProjectState project = projectCache.checkedGet(cd.change().getDest().getParentKey());
|
||||||
ListMultimap<PatchSet.Id, PatchSetApproval> all = cd.approvals();
|
ListMultimap<PatchSet.Id, PatchSetApproval> all = cd.approvals();
|
||||||
checkNotNull(all, "all should not be null");
|
requireNonNull(all, "all should not be null");
|
||||||
|
|
||||||
Table<String, Account.Id, PatchSetApproval> wontCopy = HashBasedTable.create();
|
Table<String, Account.Id, PatchSetApproval> wontCopy = HashBasedTable.create();
|
||||||
for (PatchSetApproval psa : dontCopy) {
|
for (PatchSetApproval psa : dontCopy) {
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.unwrapDb;
|
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.unwrapDb;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
@ -82,7 +82,7 @@ public class ChangeMessagesUtil {
|
|||||||
|
|
||||||
public static ChangeMessage newMessage(
|
public static ChangeMessage newMessage(
|
||||||
PatchSet.Id psId, CurrentUser user, Timestamp when, String body, @Nullable String tag) {
|
PatchSet.Id psId, CurrentUser user, Timestamp when, String body, @Nullable String tag) {
|
||||||
checkNotNull(psId);
|
requireNonNull(psId);
|
||||||
Account.Id accountId = user.isInternalUser() ? null : user.getAccountId();
|
Account.Id accountId = user.isInternalUser() ? null : user.getAccountId();
|
||||||
ChangeMessage m =
|
ChangeMessage m =
|
||||||
new ChangeMessage(
|
new ChangeMessage(
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
@ -77,9 +77,11 @@ public class CreateGroupPermissionSyncer implements ChangeMergedListener {
|
|||||||
*/
|
*/
|
||||||
public void syncIfNeeded() throws IOException, ConfigInvalidException {
|
public void syncIfNeeded() throws IOException, ConfigInvalidException {
|
||||||
ProjectState allProjectsState = projectCache.checkedGet(allProjects);
|
ProjectState allProjectsState = projectCache.checkedGet(allProjects);
|
||||||
checkNotNull(allProjectsState, "Can't obtain project state for " + allProjects);
|
requireNonNull(
|
||||||
|
allProjectsState, () -> String.format("Can't obtain project state for %s", allProjects));
|
||||||
ProjectState allUsersState = projectCache.checkedGet(allUsers);
|
ProjectState allUsersState = projectCache.checkedGet(allUsers);
|
||||||
checkNotNull(allUsersState, "Can't obtain project state for " + allUsers);
|
requireNonNull(
|
||||||
|
allUsersState, () -> String.format("Can't obtain project state for %s", allUsers));
|
||||||
|
|
||||||
Set<PermissionRule> createGroupsGlobal =
|
Set<PermissionRule> createGroupsGlobal =
|
||||||
new HashSet<>(allProjectsState.getCapabilityCollection().createGroup);
|
new HashSet<>(allProjectsState.getCapabilityCollection().createGroup);
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
import static com.google.common.collect.ImmutableMap.toImmutableMap;
|
||||||
import static com.google.gerrit.server.ChangeUtil.PS_ID_ORDER;
|
import static com.google.gerrit.server.ChangeUtil.PS_ID_ORDER;
|
||||||
import static com.google.gerrit.server.notedb.PatchSetState.PUBLISHED;
|
import static com.google.gerrit.server.notedb.PatchSetState.PUBLISHED;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.function.Function.identity;
|
import static java.util.function.Function.identity;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableCollection;
|
import com.google.common.collect.ImmutableCollection;
|
||||||
@ -130,7 +130,7 @@ public class PatchSetUtil {
|
|||||||
String pushCertificate,
|
String pushCertificate,
|
||||||
String description)
|
String description)
|
||||||
throws OrmException, IOException {
|
throws OrmException, IOException {
|
||||||
checkNotNull(groups, "groups may not be null");
|
requireNonNull(groups, "groups may not be null");
|
||||||
ensurePatchSetMatches(psId, update);
|
ensurePatchSetMatches(psId, update);
|
||||||
|
|
||||||
PatchSet ps = new PatchSet(psId);
|
PatchSet ps = new PatchSet(psId);
|
||||||
@ -197,7 +197,8 @@ public class PatchSetUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ProjectState projectState = projectCache.checkedGet(notes.getProjectName());
|
ProjectState projectState = projectCache.checkedGet(notes.getProjectName());
|
||||||
checkNotNull(projectState, "Failed to load project %s", notes.getProjectName());
|
requireNonNull(
|
||||||
|
projectState, () -> String.format("Failed to load project %s", notes.getProjectName()));
|
||||||
|
|
||||||
ApprovalsUtil approvalsUtil = approvalsUtilProvider.get();
|
ApprovalsUtil approvalsUtil = approvalsUtilProvider.get();
|
||||||
for (PatchSetApproval ap :
|
for (PatchSetApproval ap :
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server;
|
package com.google.gerrit.server;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public class StarredChangesUtil {
|
|||||||
|
|
||||||
private static StarRef create(Ref ref, Iterable<String> labels) {
|
private static StarRef create(Ref ref, Iterable<String> labels) {
|
||||||
return new AutoValue_StarredChangesUtil_StarRef(
|
return new AutoValue_StarredChangesUtil_StarRef(
|
||||||
checkNotNull(ref), ImmutableSortedSet.copyOf(labels));
|
requireNonNull(ref), ImmutableSortedSet.copyOf(labels));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -90,9 +90,9 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
|
|||||||
private List<ValidationError> validationErrors;
|
private List<ValidationError> validationErrors;
|
||||||
|
|
||||||
public AccountConfig(Account.Id accountId, AllUsersName allUsersName, Repository allUsersRepo) {
|
public AccountConfig(Account.Id accountId, AllUsersName allUsersName, Repository allUsersRepo) {
|
||||||
this.accountId = checkNotNull(accountId, "accountId");
|
this.accountId = requireNonNull(accountId, "accountId");
|
||||||
this.allUsersName = checkNotNull(allUsersName, "allUsersName");
|
this.allUsersName = requireNonNull(allUsersName, "allUsersName");
|
||||||
this.repo = checkNotNull(allUsersRepo, "allUsersRepo");
|
this.repo = requireNonNull(allUsersRepo, "allUsersRepo");
|
||||||
this.ref = RefNames.refsUsers(accountId);
|
this.ref = RefNames.refsUsers(accountId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -230,19 +230,19 @@ public class AccountsUpdate {
|
|||||||
PersonIdent authorIdent,
|
PersonIdent authorIdent,
|
||||||
Runnable afterReadRevision,
|
Runnable afterReadRevision,
|
||||||
Runnable beforeCommit) {
|
Runnable beforeCommit) {
|
||||||
this.repoManager = checkNotNull(repoManager, "repoManager");
|
this.repoManager = requireNonNull(repoManager, "repoManager");
|
||||||
this.gitRefUpdated = checkNotNull(gitRefUpdated, "gitRefUpdated");
|
this.gitRefUpdated = requireNonNull(gitRefUpdated, "gitRefUpdated");
|
||||||
this.currentUser = currentUser;
|
this.currentUser = currentUser;
|
||||||
this.allUsersName = checkNotNull(allUsersName, "allUsersName");
|
this.allUsersName = requireNonNull(allUsersName, "allUsersName");
|
||||||
this.externalIds = checkNotNull(externalIds, "externalIds");
|
this.externalIds = requireNonNull(externalIds, "externalIds");
|
||||||
this.metaDataUpdateInternalFactory =
|
this.metaDataUpdateInternalFactory =
|
||||||
checkNotNull(metaDataUpdateInternalFactory, "metaDataUpdateInternalFactory");
|
requireNonNull(metaDataUpdateInternalFactory, "metaDataUpdateInternalFactory");
|
||||||
this.retryHelper = checkNotNull(retryHelper, "retryHelper");
|
this.retryHelper = requireNonNull(retryHelper, "retryHelper");
|
||||||
this.extIdNotesLoader = checkNotNull(extIdNotesLoader, "extIdNotesLoader");
|
this.extIdNotesLoader = requireNonNull(extIdNotesLoader, "extIdNotesLoader");
|
||||||
this.committerIdent = checkNotNull(committerIdent, "committerIdent");
|
this.committerIdent = requireNonNull(committerIdent, "committerIdent");
|
||||||
this.authorIdent = checkNotNull(authorIdent, "authorIdent");
|
this.authorIdent = requireNonNull(authorIdent, "authorIdent");
|
||||||
this.afterReadRevision = checkNotNull(afterReadRevision, "afterReadRevision");
|
this.afterReadRevision = requireNonNull(afterReadRevision, "afterReadRevision");
|
||||||
this.beforeCommit = checkNotNull(beforeCommit, "beforeCommit");
|
this.beforeCommit = requireNonNull(beforeCommit, "beforeCommit");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static PersonIdent createPersonIdent(
|
private static PersonIdent createPersonIdent(
|
||||||
@ -551,11 +551,11 @@ public class AccountsUpdate {
|
|||||||
AccountConfig accountConfig,
|
AccountConfig accountConfig,
|
||||||
ExternalIdNotes extIdNotes) {
|
ExternalIdNotes extIdNotes) {
|
||||||
checkState(!Strings.isNullOrEmpty(message), "message for account update must be set");
|
checkState(!Strings.isNullOrEmpty(message), "message for account update must be set");
|
||||||
this.allUsersName = checkNotNull(allUsersName);
|
this.allUsersName = requireNonNull(allUsersName);
|
||||||
this.externalIds = checkNotNull(externalIds);
|
this.externalIds = requireNonNull(externalIds);
|
||||||
this.message = checkNotNull(message);
|
this.message = requireNonNull(message);
|
||||||
this.accountConfig = checkNotNull(accountConfig);
|
this.accountConfig = requireNonNull(accountConfig);
|
||||||
this.extIdNotes = checkNotNull(extIdNotes);
|
this.extIdNotes = requireNonNull(extIdNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.server.config.ConfigUtil.loadSection;
|
import static com.google.gerrit.server.config.ConfigUtil.loadSection;
|
||||||
import static com.google.gerrit.server.config.ConfigUtil.skipField;
|
import static com.google.gerrit.server.config.ConfigUtil.skipField;
|
||||||
@ -27,6 +26,7 @@ import static com.google.gerrit.server.git.UserConfigSections.KEY_TARGET;
|
|||||||
import static com.google.gerrit.server.git.UserConfigSections.KEY_TOKEN;
|
import static com.google.gerrit.server.git.UserConfigSections.KEY_TOKEN;
|
||||||
import static com.google.gerrit.server.git.UserConfigSections.KEY_URL;
|
import static com.google.gerrit.server.git.UserConfigSections.KEY_URL;
|
||||||
import static com.google.gerrit.server.git.UserConfigSections.URL_ALIAS;
|
import static com.google.gerrit.server.git.UserConfigSections.URL_ALIAS;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -104,10 +104,10 @@ public class Preferences {
|
|||||||
Config cfg,
|
Config cfg,
|
||||||
Config defaultCfg,
|
Config defaultCfg,
|
||||||
ValidationError.Sink validationErrorSink) {
|
ValidationError.Sink validationErrorSink) {
|
||||||
this.accountId = checkNotNull(accountId, "accountId");
|
this.accountId = requireNonNull(accountId, "accountId");
|
||||||
this.cfg = checkNotNull(cfg, "cfg");
|
this.cfg = requireNonNull(cfg, "cfg");
|
||||||
this.defaultCfg = checkNotNull(defaultCfg, "defaultCfg");
|
this.defaultCfg = requireNonNull(defaultCfg, "defaultCfg");
|
||||||
this.validationErrorSink = checkNotNull(validationErrorSink, "validationErrorSink");
|
this.validationErrorSink = requireNonNull(validationErrorSink, "validationErrorSink");
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneralPreferencesInfo getGeneralPreferences() {
|
public GeneralPreferencesInfo getGeneralPreferences() {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -112,9 +112,9 @@ public class ProjectWatches {
|
|||||||
private ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches;
|
private ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> projectWatches;
|
||||||
|
|
||||||
ProjectWatches(Account.Id accountId, Config cfg, ValidationError.Sink validationErrorSink) {
|
ProjectWatches(Account.Id accountId, Config cfg, ValidationError.Sink validationErrorSink) {
|
||||||
this.accountId = checkNotNull(accountId, "accountId");
|
this.accountId = requireNonNull(accountId, "accountId");
|
||||||
this.cfg = checkNotNull(cfg, "cfg");
|
this.cfg = requireNonNull(cfg, "cfg");
|
||||||
this.validationErrorSink = checkNotNull(validationErrorSink, "validationErrorSink");
|
this.validationErrorSink = requireNonNull(validationErrorSink, "validationErrorSink");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> getProjectWatches() {
|
public ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> getProjectWatches() {
|
||||||
|
@ -14,10 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account.externalids;
|
package com.google.gerrit.server.account.externalids;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -284,7 +284,7 @@ public abstract class ExternalId implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ExternalId createEmail(Account.Id accountId, String email) {
|
public static ExternalId createEmail(Account.Id accountId, String email) {
|
||||||
return createWithEmail(SCHEME_MAILTO, email, accountId, checkNotNull(email));
|
return createWithEmail(SCHEME_MAILTO, email, accountId, requireNonNull(email));
|
||||||
}
|
}
|
||||||
|
|
||||||
static ExternalId create(ExternalId extId, @Nullable ObjectId blobId) {
|
static ExternalId create(ExternalId extId, @Nullable ObjectId blobId) {
|
||||||
@ -331,7 +331,7 @@ public abstract class ExternalId implements Serializable {
|
|||||||
|
|
||||||
public static ExternalId parse(String noteId, Config externalIdConfig, ObjectId blobId)
|
public static ExternalId parse(String noteId, Config externalIdConfig, ObjectId blobId)
|
||||||
throws ConfigInvalidException {
|
throws ConfigInvalidException {
|
||||||
checkNotNull(blobId);
|
requireNonNull(blobId);
|
||||||
|
|
||||||
Set<String> externalIdKeys = externalIdConfig.getSubsections(EXTERNAL_ID_SECTION);
|
Set<String> externalIdKeys = externalIdConfig.getSubsections(EXTERNAL_ID_SECTION);
|
||||||
if (externalIdKeys.size() != 1) {
|
if (externalIdKeys.size() != 1) {
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account.externalids;
|
package com.google.gerrit.server.account.externalids;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
@ -284,15 +284,15 @@ public class ExternalIdNotes extends VersionedMetaData {
|
|||||||
MetricMaker metricMaker,
|
MetricMaker metricMaker,
|
||||||
AllUsersName allUsersName,
|
AllUsersName allUsersName,
|
||||||
Repository allUsersRepo) {
|
Repository allUsersRepo) {
|
||||||
this.externalIdCache = checkNotNull(externalIdCache, "externalIdCache");
|
this.externalIdCache = requireNonNull(externalIdCache, "externalIdCache");
|
||||||
this.accountCache = accountCache;
|
this.accountCache = accountCache;
|
||||||
this.accountIndexer = accountIndexer;
|
this.accountIndexer = accountIndexer;
|
||||||
this.updateCount =
|
this.updateCount =
|
||||||
metricMaker.newCounter(
|
metricMaker.newCounter(
|
||||||
"notedb/external_id_update_count",
|
"notedb/external_id_update_count",
|
||||||
new Description("Total number of external ID updates.").setRate().setUnit("updates"));
|
new Description("Total number of external ID updates.").setRate().setUnit("updates"));
|
||||||
this.allUsersName = checkNotNull(allUsersName, "allUsersRepo");
|
this.allUsersName = requireNonNull(allUsersName, "allUsersRepo");
|
||||||
this.repo = checkNotNull(allUsersRepo, "allUsersRepo");
|
this.repo = requireNonNull(allUsersRepo, "allUsersRepo");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalIdNotes setAfterReadRevision(Runnable afterReadRevision) {
|
public ExternalIdNotes setAfterReadRevision(Runnable afterReadRevision) {
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.api.accounts;
|
package com.google.gerrit.server.api.accounts;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.api.accounts.AccountApi;
|
import com.google.gerrit.extensions.api.accounts.AccountApi;
|
||||||
import com.google.gerrit.extensions.api.accounts.AccountInput;
|
import com.google.gerrit.extensions.api.accounts.AccountInput;
|
||||||
@ -95,7 +95,7 @@ public class AccountsImpl implements Accounts {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AccountApi create(AccountInput in) throws RestApiException {
|
public AccountApi create(AccountInput in) throws RestApiException {
|
||||||
if (checkNotNull(in, "AccountInput").username == null) {
|
if (requireNonNull(in, "AccountInput").username == null) {
|
||||||
throw new BadRequestException("AccountInput must specify username");
|
throw new BadRequestException("AccountInput must specify username");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.api.changes;
|
package com.google.gerrit.server.api.changes;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -128,7 +128,7 @@ class ChangesImpl implements Changes {
|
|||||||
|
|
||||||
// Check type safety of result; the extension API should be safer than the
|
// Check type safety of result; the extension API should be safer than the
|
||||||
// REST API in this case, since it's intended to be used in Java.
|
// REST API in this case, since it's intended to be used in Java.
|
||||||
Object first = checkNotNull(result.iterator().next());
|
Object first = requireNonNull(result.iterator().next());
|
||||||
checkState(first instanceof ChangeInfo);
|
checkState(first instanceof ChangeInfo);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<ChangeInfo> infos = (List<ChangeInfo>) result;
|
List<ChangeInfo> infos = (List<ChangeInfo>) result;
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.api.groups;
|
package com.google.gerrit.server.api.groups;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.api.groups.GroupApi;
|
import com.google.gerrit.extensions.api.groups.GroupApi;
|
||||||
import com.google.gerrit.extensions.api.groups.GroupInput;
|
import com.google.gerrit.extensions.api.groups.GroupInput;
|
||||||
@ -90,7 +90,7 @@ class GroupsImpl implements Groups {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GroupApi create(GroupInput in) throws RestApiException {
|
public GroupApi create(GroupInput in) throws RestApiException {
|
||||||
if (checkNotNull(in, "GroupInput").name == null) {
|
if (requireNonNull(in, "GroupInput").name == null) {
|
||||||
throw new BadRequestException("GroupInput must specify name");
|
throw new BadRequestException("GroupInput must specify name");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -14,9 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.audit;
|
package com.google.gerrit.server.audit;
|
||||||
|
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
import com.google.common.collect.ImmutableListMultimap;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
@ -64,7 +65,7 @@ public class AuditEvent {
|
|||||||
long when,
|
long when,
|
||||||
ListMultimap<String, ?> params,
|
ListMultimap<String, ?> params,
|
||||||
Object result) {
|
Object result) {
|
||||||
Preconditions.checkNotNull(what, "what is a mandatory not null param !");
|
requireNonNull(what, "what is a mandatory not null param !");
|
||||||
|
|
||||||
this.sessionId = MoreObjects.firstNonNull(sessionId, UNKNOWN_SESSION_ID);
|
this.sessionId = MoreObjects.firstNonNull(sessionId, UNKNOWN_SESSION_ID);
|
||||||
this.who = who;
|
this.who = who;
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.audit;
|
package com.google.gerrit.server.audit;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.gerrit.extensions.restapi.RestResource;
|
import com.google.gerrit.extensions.restapi.RestResource;
|
||||||
import com.google.gerrit.extensions.restapi.RestView;
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
@ -62,7 +63,7 @@ public class ExtendedHttpAuditEvent extends HttpAuditEvent {
|
|||||||
input,
|
input,
|
||||||
status,
|
status,
|
||||||
result);
|
result);
|
||||||
this.httpRequest = Preconditions.checkNotNull(httpRequest);
|
this.httpRequest = requireNonNull(httpRequest);
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.auth;
|
package com.google.gerrit.server.auth;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
@ -48,7 +48,7 @@ public class AuthUser {
|
|||||||
* @param username the name of the authenticated user.
|
* @param username the name of the authenticated user.
|
||||||
*/
|
*/
|
||||||
public AuthUser(UUID uuid, @Nullable String username) {
|
public AuthUser(UUID uuid, @Nullable String username) {
|
||||||
this.uuid = checkNotNull(uuid);
|
this.uuid = requireNonNull(uuid);
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.auth;
|
package com.google.gerrit.server.auth;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
@ -38,7 +38,7 @@ public final class UniversalAuthBackend implements AuthBackend {
|
|||||||
List<AuthException> authExs = new ArrayList<>();
|
List<AuthException> authExs = new ArrayList<>();
|
||||||
for (AuthBackend backend : authBackends) {
|
for (AuthBackend backend : authBackends) {
|
||||||
try {
|
try {
|
||||||
authUsers.add(checkNotNull(backend.authenticate(request)));
|
authUsers.add(requireNonNull(backend.authenticate(request)));
|
||||||
} catch (MissingCredentialsException ex) {
|
} catch (MissingCredentialsException ex) {
|
||||||
// Not handled by this backend.
|
// Not handled by this backend.
|
||||||
} catch (AuthException ex) {
|
} catch (AuthException ex) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.auth.oauth;
|
package com.google.gerrit.server.auth.oauth;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
@ -103,7 +103,7 @@ public class OAuthTokenCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void put(Account.Id id, OAuthToken accessToken) {
|
public void put(Account.Id id, OAuthToken accessToken) {
|
||||||
cache.put(id, encrypt(checkNotNull(accessToken)));
|
cache.put(id, encrypt(requireNonNull(accessToken)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(Account.Id id) {
|
public void remove(Account.Id id) {
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.cache;
|
package com.google.gerrit.server.cache;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
@ -99,7 +99,7 @@ class CacheProvider<K, V> implements Provider<Cache<K, V>>, CacheBinding<K, V>,
|
|||||||
@Override
|
@Override
|
||||||
public CacheBinding<K, V> configKey(String name) {
|
public CacheBinding<K, V> configKey(String name) {
|
||||||
checkNotFrozen();
|
checkNotFrozen();
|
||||||
configKey = checkNotNull(name);
|
configKey = requireNonNull(name);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.cache.serialize;
|
package com.google.gerrit.server.cache.serialize;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.protobuf.TextFormat;
|
import com.google.protobuf.TextFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -28,7 +28,7 @@ public enum BooleanCacheSerializer implements CacheSerializer<Boolean> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] serialize(Boolean object) {
|
public byte[] serialize(Boolean object) {
|
||||||
byte[] bytes = checkNotNull(object) ? TRUE : FALSE;
|
byte[] bytes = requireNonNull(object) ? TRUE : FALSE;
|
||||||
return Arrays.copyOf(bytes, bytes.length);
|
return Arrays.copyOf(bytes, bytes.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.cache.serialize;
|
package com.google.gerrit.server.cache.serialize;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Converter;
|
import com.google.common.base.Converter;
|
||||||
import com.google.common.base.Enums;
|
import com.google.common.base.Enums;
|
||||||
@ -29,11 +29,11 @@ public class EnumCacheSerializer<E extends Enum<E>> implements CacheSerializer<E
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] serialize(E object) {
|
public byte[] serialize(E object) {
|
||||||
return converter.reverse().convert(checkNotNull(object)).getBytes(UTF_8);
|
return converter.reverse().convert(requireNonNull(object)).getBytes(UTF_8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public E deserialize(byte[] in) {
|
public E deserialize(byte[] in) {
|
||||||
return converter.convert(new String(checkNotNull(in), UTF_8));
|
return converter.convert(new String(requireNonNull(in), UTF_8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.cache.serialize;
|
package com.google.gerrit.server.cache.serialize;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gwtorm.client.IntKey;
|
import com.google.gwtorm.client.IntKey;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -23,7 +23,7 @@ public class IntKeyCacheSerializer<K extends IntKey<?>> implements CacheSerializ
|
|||||||
private final Function<Integer, K> factory;
|
private final Function<Integer, K> factory;
|
||||||
|
|
||||||
public IntKeyCacheSerializer(Function<Integer, K> factory) {
|
public IntKeyCacheSerializer(Function<Integer, K> factory) {
|
||||||
this.factory = checkNotNull(factory);
|
this.factory = requireNonNull(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.cache.serialize;
|
package com.google.gerrit.server.cache.serialize;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.protobuf.CodedInputStream;
|
import com.google.protobuf.CodedInputStream;
|
||||||
import com.google.protobuf.CodedOutputStream;
|
import com.google.protobuf.CodedOutputStream;
|
||||||
@ -34,7 +34,7 @@ public enum IntegerCacheSerializer implements CacheSerializer<Integer> {
|
|||||||
byte[] buf = new byte[MAX_VARINT_SIZE];
|
byte[] buf = new byte[MAX_VARINT_SIZE];
|
||||||
CodedOutputStream cout = CodedOutputStream.newInstance(buf);
|
CodedOutputStream cout = CodedOutputStream.newInstance(buf);
|
||||||
try {
|
try {
|
||||||
cout.writeInt32NoTag(checkNotNull(object));
|
cout.writeInt32NoTag(requireNonNull(object));
|
||||||
cout.flush();
|
cout.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new IllegalStateException("Failed to serialize int");
|
throw new IllegalStateException("Failed to serialize int");
|
||||||
@ -45,7 +45,7 @@ public enum IntegerCacheSerializer implements CacheSerializer<Integer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer deserialize(byte[] in) {
|
public Integer deserialize(byte[] in) {
|
||||||
CodedInputStream cin = CodedInputStream.newInstance(checkNotNull(in));
|
CodedInputStream cin = CodedInputStream.newInstance(requireNonNull(in));
|
||||||
int ret;
|
int ret;
|
||||||
try {
|
try {
|
||||||
ret = cin.readRawVarint32();
|
ret = cin.readRawVarint32();
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
@ -77,7 +77,7 @@ public class ActionJson {
|
|||||||
List<ActionVisitor> visitors = visitors();
|
List<ActionVisitor> visitors = visitors();
|
||||||
if (!visitors.isEmpty()) {
|
if (!visitors.isEmpty()) {
|
||||||
changeInfo = changeJson().format(rsrc);
|
changeInfo = changeJson().format(rsrc);
|
||||||
revisionInfo = checkNotNull(Iterables.getOnlyElement(changeInfo.revisions.values()));
|
revisionInfo = requireNonNull(Iterables.getOnlyElement(changeInfo.revisions.values()));
|
||||||
changeInfo.revisions = null;
|
changeInfo.revisions = null;
|
||||||
}
|
}
|
||||||
return toActionMap(rsrc, visitors, changeInfo, revisionInfo);
|
return toActionMap(rsrc, visitors, changeInfo, revisionInfo);
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.gerrit.extensions.client.ReviewerState.CC;
|
import static com.google.gerrit.extensions.client.ReviewerState.CC;
|
||||||
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
|
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
@ -165,7 +165,7 @@ public class AddReviewersOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void setPatchSet(PatchSet patchSet) {
|
void setPatchSet(PatchSet patchSet) {
|
||||||
this.patchSet = checkNotNull(patchSet);
|
this.patchSet = requireNonNull(patchSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -213,7 +213,7 @@ public class AddReviewersOp implements BatchUpdateOp {
|
|||||||
checkAdded();
|
checkAdded();
|
||||||
|
|
||||||
if (patchSet == null) {
|
if (patchSet == null) {
|
||||||
patchSet = checkNotNull(psUtil.current(ctx.getDb(), ctx.getNotes()));
|
patchSet = requireNonNull(psUtil.current(ctx.getDb(), ctx.getNotes()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.gerrit.reviewdb.client.Change.INITIAL_PATCH_SET_ID;
|
import static com.google.gerrit.reviewdb.client.Change.INITIAL_PATCH_SET_ID;
|
||||||
import static com.google.gerrit.server.change.ReviewerAdder.newAddReviewerInputFromCommitIdentity;
|
import static com.google.gerrit.server.change.ReviewerAdder.newAddReviewerInputFromCommitIdentity;
|
||||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.MoreObjects;
|
import com.google.common.base.MoreObjects;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -263,7 +263,7 @@ public class ChangeInserter implements InsertChangeOp {
|
|||||||
|
|
||||||
public ChangeInserter setAccountsToNotify(
|
public ChangeInserter setAccountsToNotify(
|
||||||
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
||||||
this.accountsToNotify = checkNotNull(accountsToNotify);
|
this.accountsToNotify = requireNonNull(accountsToNotify);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ public class ChangeInserter implements InsertChangeOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ChangeInserter setGroups(List<String> groups) {
|
public ChangeInserter setGroups(List<String> groups) {
|
||||||
checkNotNull(groups, "groups may not be empty");
|
requireNonNull(groups, "groups may not be empty");
|
||||||
checkState(patchSet == null, "setGroups(Iterable<String>) only valid before creating change");
|
checkState(patchSet == null, "setGroups(Iterable<String>) only valid before creating change");
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
return this;
|
return this;
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES;
|
import static com.google.gerrit.reviewdb.client.RefNames.REFS_CHANGES;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.intKeyOrdering;
|
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.intKeyOrdering;
|
||||||
import static com.google.gerrit.server.ChangeUtil.PS_ID_ORDER;
|
import static com.google.gerrit.server.ChangeUtil.PS_ID_ORDER;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.collect.Collections2;
|
import com.google.common.collect.Collections2;
|
||||||
@ -171,7 +171,7 @@ public class ConsistencyChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Result check(ChangeNotes notes, @Nullable FixInput f) {
|
public Result check(ChangeNotes notes, @Nullable FixInput f) {
|
||||||
checkNotNull(notes);
|
requireNonNull(notes);
|
||||||
try {
|
try {
|
||||||
return retryHelper.execute(
|
return retryHelper.execute(
|
||||||
buf -> {
|
buf -> {
|
||||||
@ -530,7 +530,7 @@ public class ConsistencyChecker {
|
|||||||
if (!reuseOldPsId) {
|
if (!reuseOldPsId) {
|
||||||
bu.addOp(
|
bu.addOp(
|
||||||
notes.getChangeId(),
|
notes.getChangeId(),
|
||||||
new DeletePatchSetFromDbOp(checkNotNull(deleteOldPatchSetProblem), psIdToDelete));
|
new DeletePatchSetFromDbOp(requireNonNull(deleteOldPatchSetProblem), psIdToDelete));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,7 +759,7 @@ public class ConsistencyChecker {
|
|||||||
|
|
||||||
private ProblemInfo problem(String msg) {
|
private ProblemInfo problem(String msg) {
|
||||||
ProblemInfo p = new ProblemInfo();
|
ProblemInfo p = new ProblemInfo();
|
||||||
p.message = checkNotNull(msg);
|
p.message = requireNonNull(msg);
|
||||||
problems.add(p);
|
problems.add(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Converter;
|
import com.google.common.base.Converter;
|
||||||
import com.google.common.base.Enums;
|
import com.google.common.base.Enums;
|
||||||
@ -85,10 +85,10 @@ public class MergeabilityCacheImpl implements MergeabilityCache {
|
|||||||
"Cannot cache %s.%s",
|
"Cannot cache %s.%s",
|
||||||
SubmitType.class.getSimpleName(),
|
SubmitType.class.getSimpleName(),
|
||||||
submitType);
|
submitType);
|
||||||
this.commit = checkNotNull(commit, "commit");
|
this.commit = requireNonNull(commit, "commit");
|
||||||
this.into = checkNotNull(into, "into");
|
this.into = requireNonNull(into, "into");
|
||||||
this.submitType = checkNotNull(submitType, "submitType");
|
this.submitType = requireNonNull(submitType, "submitType");
|
||||||
this.mergeStrategy = checkNotNull(mergeStrategy, "mergeStrategy");
|
this.mergeStrategy = requireNonNull(mergeStrategy, "mergeStrategy");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectId getCommit() {
|
public ObjectId getCommit() {
|
||||||
|
@ -14,12 +14,11 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
|
import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
|
||||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
import com.google.common.collect.ImmutableListMultimap;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
@ -167,7 +166,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PatchSetInserter setGroups(List<String> groups) {
|
public PatchSetInserter setGroups(List<String> groups) {
|
||||||
checkNotNull(groups, "groups may not be null");
|
requireNonNull(groups, "groups may not be null");
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -178,13 +177,13 @@ public class PatchSetInserter implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PatchSetInserter setNotify(NotifyHandling notify) {
|
public PatchSetInserter setNotify(NotifyHandling notify) {
|
||||||
this.notify = Preconditions.checkNotNull(notify);
|
this.notify = requireNonNull(notify);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PatchSetInserter setAccountsToNotify(
|
public PatchSetInserter setAccountsToNotify(
|
||||||
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
||||||
this.accountsToNotify = checkNotNull(accountsToNotify);
|
this.accountsToNotify = requireNonNull(accountsToNotify);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,13 +15,13 @@
|
|||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.gerrit.extensions.client.ReviewerState.CC;
|
import static com.google.gerrit.extensions.client.ReviewerState.CC;
|
||||||
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
|
import static com.google.gerrit.extensions.client.ReviewerState.REVIEWER;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
import com.google.common.collect.ImmutableListMultimap;
|
||||||
@ -206,7 +206,7 @@ public class ReviewerAdder {
|
|||||||
public ReviewerAddition prepare(
|
public ReviewerAddition prepare(
|
||||||
ReviewDb db, ChangeNotes notes, CurrentUser user, AddReviewerInput input, boolean allowGroup)
|
ReviewDb db, ChangeNotes notes, CurrentUser user, AddReviewerInput input, boolean allowGroup)
|
||||||
throws OrmException, IOException, PermissionBackendException, ConfigInvalidException {
|
throws OrmException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||||
checkNotNull(input.reviewer);
|
requireNonNull(input.reviewer);
|
||||||
ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
ListMultimap<RecipientType, Account.Id> accountsToNotify;
|
||||||
try {
|
try {
|
||||||
accountsToNotify = notifyUtil.resolveAccounts(input.notifyDetails);
|
accountsToNotify = notifyUtil.resolveAccounts(input.notifyDetails);
|
||||||
@ -468,7 +468,7 @@ public class ReviewerAdder {
|
|||||||
|
|
||||||
private ReviewerAddition(AddReviewerInput input, FailureType failureType) {
|
private ReviewerAddition(AddReviewerInput input, FailureType failureType) {
|
||||||
this.input = input;
|
this.input = input;
|
||||||
this.failureType = checkNotNull(failureType);
|
this.failureType = requireNonNull(failureType);
|
||||||
result = new AddReviewerResult(input.reviewer);
|
result = new AddReviewerResult(input.reviewer);
|
||||||
op = null;
|
op = null;
|
||||||
reviewers = ImmutableSet.of();
|
reviewers = ImmutableSet.of();
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
@ -70,7 +70,7 @@ public class SetAssigneeOp implements BatchUpdateOp {
|
|||||||
this.setAssigneeSenderFactory = setAssigneeSenderFactory;
|
this.setAssigneeSenderFactory = setAssigneeSenderFactory;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.userFactory = userFactory;
|
this.userFactory = userFactory;
|
||||||
this.newAssignee = checkNotNull(newAssignee, "assignee");
|
this.newAssignee = requireNonNull(newAssignee, "assignee");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.config;
|
package com.google.gerrit.server.config;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
@ -289,7 +290,7 @@ public class ConfigUtil {
|
|||||||
Object c = f.get(s);
|
Object c = f.get(s);
|
||||||
Object d = f.get(defaults);
|
Object d = f.get(defaults);
|
||||||
if (!isString(t) && !isCollectionOrMap(t)) {
|
if (!isString(t) && !isCollectionOrMap(t)) {
|
||||||
Preconditions.checkNotNull(d, "Default cannot be null for: " + n);
|
requireNonNull(d, "Default cannot be null for: " + n);
|
||||||
}
|
}
|
||||||
if (c == null || c.equals(d)) {
|
if (c == null || c.equals(d)) {
|
||||||
cfg.unset(section, sub, n);
|
cfg.unset(section, sub, n);
|
||||||
@ -347,7 +348,7 @@ public class ConfigUtil {
|
|||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
Object d = f.get(defaults);
|
Object d = f.get(defaults);
|
||||||
if (!isString(t) && !isCollectionOrMap(t)) {
|
if (!isString(t) && !isCollectionOrMap(t)) {
|
||||||
Preconditions.checkNotNull(d, "Default cannot be null for: " + n);
|
requireNonNull(d, "Default cannot be null for: " + n);
|
||||||
}
|
}
|
||||||
if (isString(t)) {
|
if (isString(t)) {
|
||||||
String v = cfg.getString(section, sub, n);
|
String v = cfg.getString(section, sub, n);
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.config;
|
package com.google.gerrit.server.config;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.time.ZoneId.systemDefault;
|
import static java.time.ZoneId.systemDefault;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.auto.value.extension.memoized.Memoized;
|
import com.google.auto.value.extension.memoized.Memoized;
|
||||||
@ -239,7 +239,7 @@ public abstract class ScheduleConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long computeInitialDelay(long interval, String start, ZonedDateTime now) {
|
private static long computeInitialDelay(long interval, String start, ZonedDateTime now) {
|
||||||
checkNotNull(start);
|
requireNonNull(start);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("[E ]HH:mm").withLocale(Locale.US);
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("[E ]HH:mm").withLocale(Locale.US);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.edit;
|
package com.google.gerrit.server.edit;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||||
@ -35,10 +35,10 @@ public class ChangeEdit {
|
|||||||
|
|
||||||
public ChangeEdit(
|
public ChangeEdit(
|
||||||
Change change, String editRefName, RevCommit editCommit, PatchSet basePatchSet) {
|
Change change, String editRefName, RevCommit editCommit, PatchSet basePatchSet) {
|
||||||
this.change = checkNotNull(change);
|
this.change = requireNonNull(change);
|
||||||
this.editRefName = checkNotNull(editRefName);
|
this.editRefName = requireNonNull(editRefName);
|
||||||
this.editCommit = checkNotNull(editCommit);
|
this.editCommit = requireNonNull(editCommit);
|
||||||
this.basePatchSet = checkNotNull(basePatchSet);
|
this.basePatchSet = requireNonNull(basePatchSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Change getChange() {
|
public Change getChange() {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.edit.tree;
|
package com.google.gerrit.server.edit.tree;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -43,7 +43,7 @@ public class ChangeFileContentModification implements TreeModification {
|
|||||||
|
|
||||||
public ChangeFileContentModification(String filePath, RawInput newContent) {
|
public ChangeFileContentModification(String filePath, RawInput newContent) {
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
this.newContent = checkNotNull(newContent, "new content required");
|
this.newContent = requireNonNull(newContent, "new content required");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.edit.tree;
|
package com.google.gerrit.server.edit.tree;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -39,7 +39,7 @@ public class TreeCreator {
|
|||||||
private final List<TreeModification> treeModifications = new ArrayList<>();
|
private final List<TreeModification> treeModifications = new ArrayList<>();
|
||||||
|
|
||||||
public TreeCreator(RevCommit baseCommit) {
|
public TreeCreator(RevCommit baseCommit) {
|
||||||
this.baseCommit = checkNotNull(baseCommit, "baseCommit is required");
|
this.baseCommit = requireNonNull(baseCommit, "baseCommit is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -49,7 +49,7 @@ public class TreeCreator {
|
|||||||
* @param treeModifications modifications which should be applied to the base tree
|
* @param treeModifications modifications which should be applied to the base tree
|
||||||
*/
|
*/
|
||||||
public void addTreeModifications(List<TreeModification> treeModifications) {
|
public void addTreeModifications(List<TreeModification> treeModifications) {
|
||||||
checkNotNull(treeModifications, "treeModifications must not be null");
|
requireNonNull(treeModifications, "treeModifications must not be null");
|
||||||
this.treeModifications.addAll(treeModifications);
|
this.treeModifications.addAll(treeModifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.events;
|
package com.google.gerrit.server.events;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
@ -322,7 +322,7 @@ public class EventFactory {
|
|||||||
if (!ps.getRevision().get().equals(p)) {
|
if (!ps.getRevision().get().equals(p)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ca.dependsOn.add(newDependsOn(checkNotNull(cd.change()), ps));
|
ca.dependsOn.add(newDependsOn(requireNonNull(cd.change()), ps));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -357,7 +357,7 @@ public class EventFactory {
|
|||||||
if (!p.name().equals(rev)) {
|
if (!p.name().equals(rev)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ca.neededBy.add(newNeededBy(checkNotNull(cd.change()), ps));
|
ca.neededBy.add(newNeededBy(requireNonNull(cd.change()), ps));
|
||||||
continue PATCH_SETS;
|
continue PATCH_SETS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.fixes;
|
package com.google.gerrit.server.fixes;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.groupingBy;
|
import static java.util.stream.Collectors.groupingBy;
|
||||||
|
|
||||||
import com.google.gerrit.common.RawInputUtil;
|
import com.google.gerrit.common.RawInputUtil;
|
||||||
@ -70,7 +70,7 @@ public class FixReplacementInterpreter {
|
|||||||
ObjectId patchSetCommitId,
|
ObjectId patchSetCommitId,
|
||||||
List<FixReplacement> fixReplacements)
|
List<FixReplacement> fixReplacements)
|
||||||
throws ResourceNotFoundException, IOException, ResourceConflictException {
|
throws ResourceNotFoundException, IOException, ResourceConflictException {
|
||||||
checkNotNull(fixReplacements, "Fix replacements must not be null");
|
requireNonNull(fixReplacements, "Fix replacements must not be null");
|
||||||
|
|
||||||
Map<String, List<FixReplacement>> fixReplacementsPerFilePath =
|
Map<String, List<FixReplacement>> fixReplacementsPerFilePath =
|
||||||
fixReplacements.stream().collect(groupingBy(fixReplacement -> fixReplacement.path));
|
fixReplacements.stream().collect(groupingBy(fixReplacement -> fixReplacement.path));
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.fixes;
|
package com.google.gerrit.server.fixes;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@ -36,7 +36,7 @@ class LineIdentifier {
|
|||||||
private int currentLineEndIndex;
|
private int currentLineEndIndex;
|
||||||
|
|
||||||
LineIdentifier(String string) {
|
LineIdentifier(String string) {
|
||||||
checkNotNull(string);
|
requireNonNull(string);
|
||||||
lineSeparatorMatcher = LINE_SEPARATOR_PATTERN.matcher(string);
|
lineSeparatorMatcher = LINE_SEPARATOR_PATTERN.matcher(string);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.fixes;
|
package com.google.gerrit.server.fixes;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A modifier of a string. It allows to replace multiple parts of a string by indicating those parts
|
* A modifier of a string. It allows to replace multiple parts of a string by indicating those parts
|
||||||
@ -29,7 +29,7 @@ class StringModifier {
|
|||||||
private int previousEndOffset = Integer.MIN_VALUE;
|
private int previousEndOffset = Integer.MIN_VALUE;
|
||||||
|
|
||||||
StringModifier(String string) {
|
StringModifier(String string) {
|
||||||
checkNotNull(string, "string must not be null");
|
requireNonNull(string, "string must not be null");
|
||||||
stringBuilder = new StringBuilder(string);
|
stringBuilder = new StringBuilder(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class StringModifier {
|
|||||||
* previous call of this method
|
* previous call of this method
|
||||||
*/
|
*/
|
||||||
public void replace(int startIndex, int endIndex, String replacement) {
|
public void replace(int startIndex, int endIndex, String replacement) {
|
||||||
checkNotNull(replacement, "replacement string must not be null");
|
requireNonNull(replacement, "replacement string must not be null");
|
||||||
if (previousEndOffset > startIndex) {
|
if (previousEndOffset > startIndex) {
|
||||||
throw new StringIndexOutOfBoundsException(
|
throw new StringIndexOutOfBoundsException(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -40,7 +40,7 @@ public class InMemoryInserter extends ObjectInserter {
|
|||||||
private final boolean closeReader;
|
private final boolean closeReader;
|
||||||
|
|
||||||
public InMemoryInserter(ObjectReader reader) {
|
public InMemoryInserter(ObjectReader reader) {
|
||||||
this.reader = checkNotNull(reader);
|
this.reader = requireNonNull(reader);
|
||||||
closeReader = false;
|
closeReader = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -40,7 +40,7 @@ public class MergeTip {
|
|||||||
* @param toMerge list of commits to be merged in merge operation; may not be null or empty.
|
* @param toMerge list of commits to be merged in merge operation; may not be null or empty.
|
||||||
*/
|
*/
|
||||||
public MergeTip(@Nullable CodeReviewCommit initialTip, Collection<CodeReviewCommit> toMerge) {
|
public MergeTip(@Nullable CodeReviewCommit initialTip, Collection<CodeReviewCommit> toMerge) {
|
||||||
checkNotNull(toMerge, "toMerge may not be null");
|
requireNonNull(toMerge, "toMerge may not be null");
|
||||||
checkArgument(!toMerge.isEmpty(), "toMerge may not be empty");
|
checkArgument(!toMerge.isEmpty(), "toMerge may not be empty");
|
||||||
this.initialTip = initialTip;
|
this.initialTip = initialTip;
|
||||||
this.branchTip = initialTip;
|
this.branchTip = initialTip;
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
@ -129,16 +129,18 @@ public class MergeUtil {
|
|||||||
|
|
||||||
public String generate(
|
public String generate(
|
||||||
RevCommit original, RevCommit mergeTip, Branch.NameKey dest, String current) {
|
RevCommit original, RevCommit mergeTip, Branch.NameKey dest, String current) {
|
||||||
checkNotNull(original.getRawBuffer());
|
requireNonNull(original.getRawBuffer());
|
||||||
if (mergeTip != null) {
|
if (mergeTip != null) {
|
||||||
checkNotNull(mergeTip.getRawBuffer());
|
requireNonNull(mergeTip.getRawBuffer());
|
||||||
}
|
}
|
||||||
for (ChangeMessageModifier changeMessageModifier : changeMessageModifiers) {
|
for (ChangeMessageModifier changeMessageModifier : changeMessageModifiers) {
|
||||||
current = changeMessageModifier.onSubmit(current, original, mergeTip, dest);
|
current = changeMessageModifier.onSubmit(current, original, mergeTip, dest);
|
||||||
checkNotNull(
|
requireNonNull(
|
||||||
current,
|
current,
|
||||||
changeMessageModifier.getClass().getName()
|
() ->
|
||||||
+ ".OnSubmit returned null instead of new commit message");
|
String.format(
|
||||||
|
"%s.OnSubmit returned null instead of new commit message",
|
||||||
|
changeMessageModifier.getClass().getName()));
|
||||||
}
|
}
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git;
|
package com.google.gerrit.server.git;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.gerrit.reviewdb.client.Change;
|
import com.google.gerrit.reviewdb.client.Change;
|
||||||
@ -101,7 +101,7 @@ public class MergedByPushOp implements BatchUpdateOp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MergedByPushOp setPatchSetProvider(Provider<PatchSet> patchSetProvider) {
|
public MergedByPushOp setPatchSetProvider(Provider<PatchSet> patchSetProvider) {
|
||||||
this.patchSetProvider = checkNotNull(patchSetProvider);
|
this.patchSetProvider = requireNonNull(patchSetProvider);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,8 +119,9 @@ public class MergedByPushOp implements BatchUpdateOp {
|
|||||||
patchSet = patchSetProvider.get();
|
patchSet = patchSetProvider.get();
|
||||||
} else {
|
} else {
|
||||||
patchSet =
|
patchSet =
|
||||||
checkNotNull(
|
requireNonNull(
|
||||||
psUtil.get(ctx.getDb(), ctx.getNotes(), psId), "patch set %s not found", psId);
|
psUtil.get(ctx.getDb(), ctx.getNotes(), psId),
|
||||||
|
() -> String.format("patch set %s not found", psId));
|
||||||
}
|
}
|
||||||
info = getPatchSetInfo(ctx);
|
info = getPatchSetInfo(ctx);
|
||||||
|
|
||||||
@ -198,7 +199,7 @@ public class MergedByPushOp implements BatchUpdateOp {
|
|||||||
private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, OrmException {
|
private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, OrmException {
|
||||||
RevWalk rw = ctx.getRevWalk();
|
RevWalk rw = ctx.getRevWalk();
|
||||||
RevCommit commit =
|
RevCommit commit =
|
||||||
rw.parseCommit(ObjectId.fromString(checkNotNull(patchSet).getRevision().get()));
|
rw.parseCommit(ObjectId.fromString(requireNonNull(patchSet).getRevision().get()));
|
||||||
return patchSetInfoFactory.get(rw, commit, psId);
|
return patchSetInfoFactory.get(rw, commit, psId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ package com.google.gerrit.server.git.receive;
|
|||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
import static com.google.gerrit.common.FooterConstants.CHANGE_ID;
|
import static com.google.gerrit.common.FooterConstants.CHANGE_ID;
|
||||||
@ -32,6 +31,7 @@ import static com.google.gerrit.server.git.validators.CommitValidators.NEW_PATCH
|
|||||||
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
|
import static com.google.gerrit.server.mail.MailUtil.getRecipientsFromFooters;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Comparator.comparingInt;
|
import static java.util.Comparator.comparingInt;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
import static org.eclipse.jgit.lib.Constants.R_HEADS;
|
||||||
@ -2428,7 +2428,7 @@ class ReceiveCommits {
|
|||||||
final PatchSet.Id psId = ins.setGroups(groups).getPatchSetId();
|
final PatchSet.Id psId = ins.setGroups(groups).getPatchSetId();
|
||||||
Account.Id me = user.getAccountId();
|
Account.Id me = user.getAccountId();
|
||||||
List<FooterLine> footerLines = commit.getFooterLines();
|
List<FooterLine> footerLines = commit.getFooterLines();
|
||||||
checkNotNull(magicBranch);
|
requireNonNull(magicBranch);
|
||||||
|
|
||||||
// TODO(dborowitz): Support reviewers by email from footers? Maybe not: kernel developers
|
// TODO(dborowitz): Support reviewers by email from footers? Maybe not: kernel developers
|
||||||
// with AOSP accounts already complain about these notifications, and that would make it
|
// with AOSP accounts already complain about these notifications, and that would make it
|
||||||
@ -2496,15 +2496,20 @@ class ReceiveCommits {
|
|||||||
PermissionBackendException {
|
PermissionBackendException {
|
||||||
Map<ObjectId, Change> bySha = Maps.newHashMapWithExpectedSize(create.size() + replace.size());
|
Map<ObjectId, Change> bySha = Maps.newHashMapWithExpectedSize(create.size() + replace.size());
|
||||||
for (CreateRequest r : create) {
|
for (CreateRequest r : create) {
|
||||||
checkNotNull(r.change, "cannot submit new change %s; op may not have run", r.changeId);
|
requireNonNull(
|
||||||
|
r.change,
|
||||||
|
() -> String.format("cannot submit new change %s; op may not have run", r.changeId));
|
||||||
bySha.put(r.commit, r.change);
|
bySha.put(r.commit, r.change);
|
||||||
}
|
}
|
||||||
for (ReplaceRequest r : replace) {
|
for (ReplaceRequest r : replace) {
|
||||||
bySha.put(r.newCommitId, r.notes.getChange());
|
bySha.put(r.newCommitId, r.notes.getChange());
|
||||||
}
|
}
|
||||||
Change tipChange = bySha.get(magicBranch.cmd.getNewId());
|
Change tipChange = bySha.get(magicBranch.cmd.getNewId());
|
||||||
checkNotNull(
|
requireNonNull(
|
||||||
tipChange, "tip of push does not correspond to a change; found these changes: %s", bySha);
|
tipChange,
|
||||||
|
() ->
|
||||||
|
String.format(
|
||||||
|
"tip of push does not correspond to a change; found these changes: %s", bySha));
|
||||||
logger.atFine().log(
|
logger.atFine().log(
|
||||||
"Processing submit with tip change %s (%s)", tipChange.getId(), magicBranch.cmd.getNewId());
|
"Processing submit with tip change %s (%s)", tipChange.getId(), magicBranch.cmd.getNewId());
|
||||||
try (MergeOp op = mergeOpProvider.get()) {
|
try (MergeOp op = mergeOpProvider.get()) {
|
||||||
@ -2573,7 +2578,7 @@ class ReceiveCommits {
|
|||||||
Change.Id toChange, RevCommit newCommit, ReceiveCommand cmd, boolean checkMergedInto) {
|
Change.Id toChange, RevCommit newCommit, ReceiveCommand cmd, boolean checkMergedInto) {
|
||||||
this.ontoChange = toChange;
|
this.ontoChange = toChange;
|
||||||
this.newCommitId = newCommit.copy();
|
this.newCommitId = newCommit.copy();
|
||||||
this.inputCommand = checkNotNull(cmd);
|
this.inputCommand = requireNonNull(cmd);
|
||||||
this.checkMergedInto = checkMergedInto;
|
this.checkMergedInto = checkMergedInto;
|
||||||
|
|
||||||
revisions = HashBiMap.create();
|
revisions = HashBiMap.create();
|
||||||
@ -2853,7 +2858,7 @@ class ReceiveCommits {
|
|||||||
List<String> groups = ImmutableList.of();
|
List<String> groups = ImmutableList.of();
|
||||||
|
|
||||||
UpdateGroupsRequest(Ref ref, RevCommit commit) {
|
UpdateGroupsRequest(Ref ref, RevCommit commit) {
|
||||||
this.psId = checkNotNull(PatchSet.Id.fromRef(ref.getName()));
|
this.psId = requireNonNull(PatchSet.Id.fromRef(ref.getName()));
|
||||||
this.commit = commit;
|
this.commit = commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2887,7 +2892,7 @@ class ReceiveCommits {
|
|||||||
final ReceiveCommand cmd;
|
final ReceiveCommand cmd;
|
||||||
|
|
||||||
private UpdateOneRefOp(ReceiveCommand cmd) {
|
private UpdateOneRefOp(ReceiveCommand cmd) {
|
||||||
this.cmd = checkNotNull(cmd);
|
this.cmd = requireNonNull(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.git.validators;
|
package com.google.gerrit.server.git.validators;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
import com.google.gerrit.extensions.annotations.ExtensionPoint;
|
||||||
@ -52,9 +52,9 @@ public interface OnSubmitValidationListener {
|
|||||||
* @param commands commands to be executed.
|
* @param commands commands to be executed.
|
||||||
*/
|
*/
|
||||||
Arguments(Project.NameKey project, RevWalk rw, ChainedReceiveCommands commands) {
|
Arguments(Project.NameKey project, RevWalk rw, ChainedReceiveCommands commands) {
|
||||||
this.project = checkNotNull(project);
|
this.project = requireNonNull(project);
|
||||||
this.rw = checkNotNull(rw);
|
this.rw = requireNonNull(rw);
|
||||||
this.refs = checkNotNull(commands);
|
this.refs = requireNonNull(commands);
|
||||||
this.commands = ImmutableMap.copyOf(commands.getCommands());
|
this.commands = ImmutableMap.copyOf(commands.getCommands());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group;
|
package com.google.gerrit.server.group;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
@ -29,7 +29,7 @@ public class InternalGroupDescription implements GroupDescription.Internal {
|
|||||||
private final InternalGroup internalGroup;
|
private final InternalGroup internalGroup;
|
||||||
|
|
||||||
public InternalGroupDescription(InternalGroup internalGroup) {
|
public InternalGroupDescription(InternalGroup internalGroup) {
|
||||||
this.internalGroup = checkNotNull(internalGroup);
|
this.internalGroup = requireNonNull(internalGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group;
|
package com.google.gerrit.server.group;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toSet;
|
import static java.util.stream.Collectors.toSet;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -117,7 +117,7 @@ public class SystemGroupBackend extends AbstractGroupBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GroupReference getGroup(AccountGroup.UUID uuid) {
|
public GroupReference getGroup(AccountGroup.UUID uuid) {
|
||||||
return checkNotNull(uuids.get(uuid), "group %s not found", uuid.get());
|
return requireNonNull(uuids.get(uuid), () -> String.format("group %s not found", uuid.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getNames() {
|
public Set<String> getNames() {
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group.db;
|
package com.google.gerrit.server.group.db;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
@ -90,16 +90,16 @@ public class AuditLogFormatter {
|
|||||||
Function<Account.Id, Optional<Account>> accountRetriever,
|
Function<Account.Id, Optional<Account>> accountRetriever,
|
||||||
Function<AccountGroup.UUID, Optional<GroupDescription.Basic>> groupRetriever,
|
Function<AccountGroup.UUID, Optional<GroupDescription.Basic>> groupRetriever,
|
||||||
String serverId) {
|
String serverId) {
|
||||||
this.accountRetriever = checkNotNull(accountRetriever);
|
this.accountRetriever = requireNonNull(accountRetriever);
|
||||||
this.groupRetriever = checkNotNull(groupRetriever);
|
this.groupRetriever = requireNonNull(groupRetriever);
|
||||||
this.serverId = checkNotNull(serverId);
|
this.serverId = requireNonNull(serverId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AuditLogFormatter(
|
private AuditLogFormatter(
|
||||||
Function<Account.Id, Optional<Account>> accountRetriever,
|
Function<Account.Id, Optional<Account>> accountRetriever,
|
||||||
Function<AccountGroup.UUID, Optional<GroupDescription.Basic>> groupRetriever) {
|
Function<AccountGroup.UUID, Optional<GroupDescription.Basic>> groupRetriever) {
|
||||||
this.accountRetriever = checkNotNull(accountRetriever);
|
this.accountRetriever = requireNonNull(accountRetriever);
|
||||||
this.groupRetriever = checkNotNull(groupRetriever);
|
this.groupRetriever = requireNonNull(groupRetriever);
|
||||||
serverId = null;
|
serverId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group.db;
|
package com.google.gerrit.server.group.db;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
import static com.google.common.collect.ImmutableSet.toImmutableSet;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -187,7 +187,7 @@ public class GroupConfig extends VersionedMetaData {
|
|||||||
private boolean allowSaveEmptyName;
|
private boolean allowSaveEmptyName;
|
||||||
|
|
||||||
private GroupConfig(AccountGroup.UUID groupUuid) {
|
private GroupConfig(AccountGroup.UUID groupUuid) {
|
||||||
this.groupUuid = checkNotNull(groupUuid);
|
this.groupUuid = requireNonNull(groupUuid);
|
||||||
ref = RefNames.refsGroups(groupUuid);
|
ref = RefNames.refsGroups(groupUuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group.db;
|
package com.google.gerrit.server.group.db;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.collect.ImmutableBiMap.toImmutableBiMap;
|
import static com.google.common.collect.ImmutableBiMap.toImmutableBiMap;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -123,8 +123,8 @@ public class GroupNameNotes extends VersionedMetaData {
|
|||||||
AccountGroup.NameKey oldName,
|
AccountGroup.NameKey oldName,
|
||||||
AccountGroup.NameKey newName)
|
AccountGroup.NameKey newName)
|
||||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||||
checkNotNull(oldName);
|
requireNonNull(oldName);
|
||||||
checkNotNull(newName);
|
requireNonNull(newName);
|
||||||
|
|
||||||
GroupNameNotes groupNameNotes = new GroupNameNotes(groupUuid, oldName, newName);
|
GroupNameNotes groupNameNotes = new GroupNameNotes(groupUuid, oldName, newName);
|
||||||
groupNameNotes.load(projectName, repository);
|
groupNameNotes.load(projectName, repository);
|
||||||
@ -154,7 +154,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
|||||||
AccountGroup.UUID groupUuid,
|
AccountGroup.UUID groupUuid,
|
||||||
AccountGroup.NameKey groupName)
|
AccountGroup.NameKey groupName)
|
||||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||||
checkNotNull(groupName);
|
requireNonNull(groupName);
|
||||||
|
|
||||||
GroupNameNotes groupNameNotes = new GroupNameNotes(groupUuid, null, groupName);
|
GroupNameNotes groupNameNotes = new GroupNameNotes(groupUuid, null, groupName);
|
||||||
groupNameNotes.load(projectName, repository);
|
groupNameNotes.load(projectName, repository);
|
||||||
@ -313,7 +313,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
|||||||
AccountGroup.UUID groupUuid,
|
AccountGroup.UUID groupUuid,
|
||||||
@Nullable AccountGroup.NameKey oldGroupName,
|
@Nullable AccountGroup.NameKey oldGroupName,
|
||||||
@Nullable AccountGroup.NameKey newGroupName) {
|
@Nullable AccountGroup.NameKey newGroupName) {
|
||||||
this.groupUuid = checkNotNull(groupUuid);
|
this.groupUuid = requireNonNull(groupUuid);
|
||||||
|
|
||||||
if (Objects.equals(oldGroupName, newGroupName)) {
|
if (Objects.equals(oldGroupName, newGroupName)) {
|
||||||
this.oldGroupName = Optional.empty();
|
this.oldGroupName = Optional.empty();
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.group.testing;
|
package com.google.gerrit.server.group.testing;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.gerrit.common.data.GroupDescription;
|
import com.google.gerrit.common.data.GroupDescription;
|
||||||
@ -42,7 +42,7 @@ public class TestGroupBackend implements GroupBackend {
|
|||||||
* @return the created group
|
* @return the created group
|
||||||
*/
|
*/
|
||||||
public GroupDescription.Basic create(String name) {
|
public GroupDescription.Basic create(String name) {
|
||||||
checkNotNull(name);
|
requireNonNull(name);
|
||||||
return create(new AccountGroup.UUID(name.startsWith(PREFIX) ? name : PREFIX + name));
|
return create(new AccountGroup.UUID(name.startsWith(PREFIX) ? name : PREFIX + name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index;
|
package com.google.gerrit.server.index;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
@ -98,11 +98,9 @@ public class OnlineReindexer<K, V, I extends Index<K, V>> {
|
|||||||
listener.onStart(name, oldVersion, newVersion);
|
listener.onStart(name, oldVersion, newVersion);
|
||||||
}
|
}
|
||||||
index =
|
index =
|
||||||
checkNotNull(
|
requireNonNull(
|
||||||
indexes.getWriteIndex(newVersion),
|
indexes.getWriteIndex(newVersion),
|
||||||
"not an active write schema version: %s %s",
|
() -> String.format("not an active write schema version: %s %s", name, newVersion));
|
||||||
name,
|
|
||||||
newVersion);
|
|
||||||
logger.atInfo().log(
|
logger.atInfo().log(
|
||||||
"Starting online reindex of %s from schema version %s to %s",
|
"Starting online reindex of %s from schema version %s to %s",
|
||||||
name, version(indexes.getSearchIndex()), version(index));
|
name, version(indexes.getSearchIndex()), version(index));
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index.account;
|
package com.google.gerrit.server.index.account;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.index.IndexRewriter;
|
import com.google.gerrit.index.IndexRewriter;
|
||||||
import com.google.gerrit.index.QueryOptions;
|
import com.google.gerrit.index.QueryOptions;
|
||||||
@ -38,7 +38,7 @@ public class AccountIndexRewriter implements IndexRewriter<AccountState> {
|
|||||||
public Predicate<AccountState> rewrite(Predicate<AccountState> in, QueryOptions opts)
|
public Predicate<AccountState> rewrite(Predicate<AccountState> in, QueryOptions opts)
|
||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
AccountIndex index = indexes.getSearchIndex();
|
AccountIndex index = indexes.getSearchIndex();
|
||||||
checkNotNull(index, "no active search index configured for accounts");
|
requireNonNull(index, "no active search index configured for accounts");
|
||||||
return new IndexedAccountQuery(index, in, opts);
|
return new IndexedAccountQuery(index, in, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index.account;
|
package com.google.gerrit.server.index.account;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Splitter;
|
import com.google.common.base.Splitter;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
@ -140,7 +140,7 @@ public class StalenessChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (byte[] b : extIdStates) {
|
for (byte[] b : extIdStates) {
|
||||||
checkNotNull(b, "invalid external ID state");
|
requireNonNull(b, "invalid external ID state");
|
||||||
String s = new String(b, UTF_8);
|
String s = new String(b, UTF_8);
|
||||||
List<String> parts = Splitter.on(':').splitToList(s);
|
List<String> parts = Splitter.on(':').splitToList(s);
|
||||||
checkState(parts.size() == 2, "invalid external ID state: %s", s);
|
checkState(parts.size() == 2, "invalid external ID state: %s", s);
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
package com.google.gerrit.server.index.change;
|
package com.google.gerrit.server.index.change;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
@ -136,7 +136,7 @@ public class StalenessChecker {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static boolean reviewDbChangeIsStale(Change indexChange, @Nullable Change reviewDbChange) {
|
static boolean reviewDbChangeIsStale(Change indexChange, @Nullable Change reviewDbChange) {
|
||||||
checkNotNull(indexChange);
|
requireNonNull(indexChange);
|
||||||
PrimaryStorage storageFromIndex = PrimaryStorage.of(indexChange);
|
PrimaryStorage storageFromIndex = PrimaryStorage.of(indexChange);
|
||||||
PrimaryStorage storageFromReviewDb = PrimaryStorage.of(reviewDbChange);
|
PrimaryStorage storageFromReviewDb = PrimaryStorage.of(reviewDbChange);
|
||||||
if (reviewDbChange == null) {
|
if (reviewDbChange == null) {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.index.group;
|
package com.google.gerrit.server.index.group;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.index.IndexRewriter;
|
import com.google.gerrit.index.IndexRewriter;
|
||||||
import com.google.gerrit.index.QueryOptions;
|
import com.google.gerrit.index.QueryOptions;
|
||||||
@ -37,7 +37,7 @@ public class GroupIndexRewriter implements IndexRewriter<InternalGroup> {
|
|||||||
public Predicate<InternalGroup> rewrite(Predicate<InternalGroup> in, QueryOptions opts)
|
public Predicate<InternalGroup> rewrite(Predicate<InternalGroup> in, QueryOptions opts)
|
||||||
throws QueryParseException {
|
throws QueryParseException {
|
||||||
GroupIndex index = indexes.getSearchIndex();
|
GroupIndex index = indexes.getSearchIndex();
|
||||||
checkNotNull(index, "no active search index configured for groups");
|
requireNonNull(index, "no active search index configured for groups");
|
||||||
return new IndexedGroupQuery(index, in, opts);
|
return new IndexedGroupQuery(index, in, opts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.ioutil;
|
package com.google.gerrit.server.ioutil;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.primitives.Chars;
|
import com.google.common.primitives.Chars;
|
||||||
@ -41,7 +41,7 @@ public final class RegexListSearcher<T> {
|
|||||||
private final boolean prefixOnly;
|
private final boolean prefixOnly;
|
||||||
|
|
||||||
public RegexListSearcher(String re, Function<T, String> toStringFunc) {
|
public RegexListSearcher(String re, Function<T, String> toStringFunc) {
|
||||||
this.toStringFunc = checkNotNull(toStringFunc);
|
this.toStringFunc = requireNonNull(toStringFunc);
|
||||||
|
|
||||||
if (re.startsWith("^")) {
|
if (re.startsWith("^")) {
|
||||||
re = re.substring(1);
|
re = re.substring(1);
|
||||||
@ -68,7 +68,7 @@ public final class RegexListSearcher<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Stream<T> search(List<T> list) {
|
public Stream<T> search(List<T> list) {
|
||||||
checkNotNull(list);
|
requireNonNull(list);
|
||||||
int begin;
|
int begin;
|
||||||
int end;
|
int end;
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.logging;
|
package com.google.gerrit.server.logging;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
import com.google.common.collect.MultimapBuilder;
|
import com.google.common.collect.MultimapBuilder;
|
||||||
@ -39,8 +39,8 @@ public class MutableTags {
|
|||||||
* already exists
|
* already exists
|
||||||
*/
|
*/
|
||||||
public boolean add(String name, String value) {
|
public boolean add(String name, String value) {
|
||||||
checkNotNull(name, "tag name is required");
|
requireNonNull(name, "tag name is required");
|
||||||
checkNotNull(value, "tag value is required");
|
requireNonNull(value, "tag value is required");
|
||||||
boolean ret = tagMap.put(name, value);
|
boolean ret = tagMap.put(name, value);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
buildTags();
|
buildTags();
|
||||||
@ -55,8 +55,8 @@ public class MutableTags {
|
|||||||
* @param value the value of the tag
|
* @param value the value of the tag
|
||||||
*/
|
*/
|
||||||
public void remove(String name, String value) {
|
public void remove(String name, String value) {
|
||||||
checkNotNull(name, "tag name is required");
|
requireNonNull(name, "tag name is required");
|
||||||
checkNotNull(value, "tag value is required");
|
requireNonNull(value, "tag value is required");
|
||||||
if (tagMap.remove(name, value)) {
|
if (tagMap.remove(name, value)) {
|
||||||
buildTags();
|
buildTags();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.logging;
|
package com.google.gerrit.server.logging;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
@ -252,12 +252,12 @@ public class TraceContext implements AutoCloseable {
|
|||||||
private TraceContext() {}
|
private TraceContext() {}
|
||||||
|
|
||||||
public TraceContext addTag(RequestId.Type requestId, Object tagValue) {
|
public TraceContext addTag(RequestId.Type requestId, Object tagValue) {
|
||||||
return addTag(checkNotNull(requestId, "request ID is required").name(), tagValue);
|
return addTag(requireNonNull(requestId, "request ID is required").name(), tagValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TraceContext addTag(String tagName, Object tagValue) {
|
public TraceContext addTag(String tagName, Object tagValue) {
|
||||||
String name = checkNotNull(tagName, "tag name is required");
|
String name = requireNonNull(tagName, "tag name is required");
|
||||||
String value = checkNotNull(tagValue, "tag value is required").toString();
|
String value = requireNonNull(tagValue, "tag value is required").toString();
|
||||||
tags.put(name, value, LoggingContext.getInstance().addTag(name, value));
|
tags.put(name, value, LoggingContext.getInstance().addTag(name, value));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.common.errors.EmailException;
|
import com.google.gerrit.common.errors.EmailException;
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
@ -47,9 +47,9 @@ public class InboundEmailRejectionSender extends OutgoingEmail {
|
|||||||
public InboundEmailRejectionSender(
|
public InboundEmailRejectionSender(
|
||||||
EmailArguments ea, @Assisted Address to, @Assisted String threadId, @Assisted Error reason) {
|
EmailArguments ea, @Assisted Address to, @Assisted String threadId, @Assisted Error reason) {
|
||||||
super(ea, "error");
|
super(ea, "error");
|
||||||
this.to = checkNotNull(to);
|
this.to = requireNonNull(to);
|
||||||
this.threadId = checkNotNull(threadId);
|
this.threadId = requireNonNull(threadId);
|
||||||
this.reason = checkNotNull(reason);
|
this.reason = requireNonNull(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.CC_ON_OWN_COMMENTS;
|
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.CC_ON_OWN_COMMENTS;
|
||||||
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.DISABLED;
|
import static com.google.gerrit.extensions.client.GeneralPreferencesInfo.EmailStrategy.DISABLED;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
import com.google.common.collect.ImmutableListMultimap;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
@ -84,11 +84,11 @@ public abstract class OutgoingEmail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setNotify(NotifyHandling notify) {
|
public void setNotify(NotifyHandling notify) {
|
||||||
this.notify = checkNotNull(notify);
|
this.notify = requireNonNull(notify);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountsToNotify(ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
public void setAccountsToNotify(ListMultimap<RecipientType, Account.Id> accountsToNotify) {
|
||||||
this.accountsToNotify = checkNotNull(accountsToNotify);
|
this.accountsToNotify = requireNonNull(accountsToNotify);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.mail.send;
|
package com.google.gerrit.server.mail.send;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.gerrit.common.errors.EmailException;
|
import com.google.gerrit.common.errors.EmailException;
|
||||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||||
@ -64,7 +64,7 @@ public class RegisterNewEmailSender extends OutgoingEmail {
|
|||||||
|
|
||||||
public String getEmailRegistrationToken() {
|
public String getEmailRegistrationToken() {
|
||||||
if (emailToken == null) {
|
if (emailToken == null) {
|
||||||
emailToken = checkNotNull(tokenVerifier.encode(user.getAccountId(), addr), "token");
|
emailToken = requireNonNull(tokenVerifier.encode(user.getAccountId(), addr), "token");
|
||||||
}
|
}
|
||||||
return emailToken;
|
return emailToken;
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -92,7 +92,7 @@ public abstract class AbstractChangeNotes<T> {
|
|||||||
} else if (id != null) {
|
} else if (id != null) {
|
||||||
id = id.copy();
|
id = id.copy();
|
||||||
}
|
}
|
||||||
return new AutoValue_AbstractChangeNotes_LoadHandle(checkNotNull(walk), id);
|
return new AutoValue_AbstractChangeNotes_LoadHandle(requireNonNull(walk), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LoadHandle missing() {
|
public static LoadHandle missing() {
|
||||||
@ -123,8 +123,8 @@ public abstract class AbstractChangeNotes<T> {
|
|||||||
|
|
||||||
AbstractChangeNotes(
|
AbstractChangeNotes(
|
||||||
Args args, Change.Id changeId, @Nullable PrimaryStorage primaryStorage, boolean autoRebuild) {
|
Args args, Change.Id changeId, @Nullable PrimaryStorage primaryStorage, boolean autoRebuild) {
|
||||||
this.args = checkNotNull(args);
|
this.args = requireNonNull(args);
|
||||||
this.changeId = checkNotNull(changeId);
|
this.changeId = requireNonNull(changeId);
|
||||||
this.primaryStorage = primaryStorage;
|
this.primaryStorage = primaryStorage;
|
||||||
this.autoRebuild =
|
this.autoRebuild =
|
||||||
primaryStorage == PrimaryStorage.REVIEW_DB
|
primaryStorage == PrimaryStorage.REVIEW_DB
|
||||||
|
@ -16,7 +16,6 @@ package com.google.gerrit.server.notedb;
|
|||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
import static com.google.common.collect.ImmutableSortedMap.toImmutableSortedMap;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.checkColumns;
|
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.checkColumns;
|
||||||
@ -27,6 +26,7 @@ import static com.google.gerrit.server.util.time.TimeUtil.truncateToSecond;
|
|||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
import static java.util.Comparator.naturalOrder;
|
import static java.util.Comparator.naturalOrder;
|
||||||
import static java.util.Comparator.nullsFirst;
|
import static java.util.Comparator.nullsFirst;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
@ -203,13 +203,13 @@ public class ChangeBundle {
|
|||||||
Iterable<PatchLineComment> patchLineComments,
|
Iterable<PatchLineComment> patchLineComments,
|
||||||
ReviewerSet reviewers,
|
ReviewerSet reviewers,
|
||||||
Source source) {
|
Source source) {
|
||||||
this.change = checkNotNull(change);
|
this.change = requireNonNull(change);
|
||||||
this.changeMessages = changeMessageList(changeMessages);
|
this.changeMessages = changeMessageList(changeMessages);
|
||||||
this.patchSets = ImmutableSortedMap.copyOfSorted(patchSetMap(patchSets));
|
this.patchSets = ImmutableSortedMap.copyOfSorted(patchSetMap(patchSets));
|
||||||
this.patchSetApprovals = ImmutableMap.copyOf(patchSetApprovalMap(patchSetApprovals));
|
this.patchSetApprovals = ImmutableMap.copyOf(patchSetApprovalMap(patchSetApprovals));
|
||||||
this.patchLineComments = ImmutableMap.copyOf(patchLineCommentMap(patchLineComments));
|
this.patchLineComments = ImmutableMap.copyOf(patchLineCommentMap(patchLineComments));
|
||||||
this.reviewers = checkNotNull(reviewers);
|
this.reviewers = requireNonNull(reviewers);
|
||||||
this.source = checkNotNull(source);
|
this.source = requireNonNull(source);
|
||||||
|
|
||||||
for (ChangeMessage m : this.changeMessages) {
|
for (ChangeMessage m : this.changeMessages) {
|
||||||
checkArgument(m.getKey().getParentKey().equals(change.getId()));
|
checkArgument(m.getKey().getParentKey().equals(change.getId()));
|
||||||
@ -706,8 +706,8 @@ public class ChangeBundle {
|
|||||||
// purposes, ignore the postSubmit bit in NoteDb in this case.
|
// purposes, ignore the postSubmit bit in NoteDb in this case.
|
||||||
Timestamp ta = a.getGranted();
|
Timestamp ta = a.getGranted();
|
||||||
Timestamp tb = b.getGranted();
|
Timestamp tb = b.getGranted();
|
||||||
PatchSet psa = checkNotNull(bundleA.patchSets.get(a.getPatchSetId()));
|
PatchSet psa = requireNonNull(bundleA.patchSets.get(a.getPatchSetId()));
|
||||||
PatchSet psb = checkNotNull(bundleB.patchSets.get(b.getPatchSetId()));
|
PatchSet psb = requireNonNull(bundleB.patchSets.get(b.getPatchSetId()));
|
||||||
boolean excludeGranted = false;
|
boolean excludeGranted = false;
|
||||||
boolean excludePostSubmit = false;
|
boolean excludePostSubmit = false;
|
||||||
List<String> exclude = new ArrayList<>(1);
|
List<String> exclude = new ArrayList<>(1);
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -655,7 +655,8 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
|
|
||||||
public PatchSet getCurrentPatchSet() {
|
public PatchSet getCurrentPatchSet() {
|
||||||
PatchSet.Id psId = change.currentPatchSetId();
|
PatchSet.Id psId = change.currentPatchSetId();
|
||||||
return checkNotNull(getPatchSets().get(psId), "missing current patch set %s", psId.get());
|
return requireNonNull(
|
||||||
|
getPatchSets().get(psId), () -> String.format("missing current patch set %s", psId.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@ -761,10 +762,10 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
// to the caller instead of throwing.
|
// to the caller instead of throwing.
|
||||||
logger.atFine().log("Rebuilding change %s failed: %s", getChangeId(), e.getMessage());
|
logger.atFine().log("Rebuilding change %s failed: %s", getChangeId(), e.getMessage());
|
||||||
args.metrics.autoRebuildFailureCount.increment(CHANGES);
|
args.metrics.autoRebuildFailureCount.increment(CHANGES);
|
||||||
rebuildResult = checkNotNull(r);
|
rebuildResult = requireNonNull(r);
|
||||||
checkNotNull(r.newState());
|
requireNonNull(r.newState());
|
||||||
checkNotNull(r.staged());
|
requireNonNull(r.staged());
|
||||||
checkNotNull(r.staged().changeObjects());
|
requireNonNull(r.staged().changeObjects());
|
||||||
return LoadHandle.create(
|
return LoadHandle.create(
|
||||||
ChangeNotesCommit.newStagedRevWalk(repo, r.staged().changeObjects()),
|
ChangeNotesCommit.newStagedRevWalk(repo, r.staged().changeObjects()),
|
||||||
r.newState().getChangeMetaId());
|
r.newState().getChangeMetaId());
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.collect.ImmutableList.toImmutableList;
|
import static com.google.common.collect.ImmutableList.toImmutableList;
|
||||||
import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
|
import static com.google.common.collect.ImmutableListMultimap.toImmutableListMultimap;
|
||||||
@ -24,6 +23,7 @@ import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.APPROVAL_CODEC;
|
|||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.MESSAGE_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.MESSAGE_CODEC;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.PATCH_SET_CODEC;
|
import static com.google.gerrit.reviewdb.server.ReviewDbCodecs.PATCH_SET_CODEC;
|
||||||
import static com.google.gerrit.server.cache.serialize.ProtoCacheSerializers.toByteString;
|
import static com.google.gerrit.server.cache.serialize.ProtoCacheSerializers.toByteString;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -123,11 +123,14 @@ public abstract class ChangeNotesState {
|
|||||||
boolean workInProgress,
|
boolean workInProgress,
|
||||||
boolean reviewStarted,
|
boolean reviewStarted,
|
||||||
@Nullable Change.Id revertOf) {
|
@Nullable Change.Id revertOf) {
|
||||||
checkNotNull(
|
requireNonNull(
|
||||||
metaId,
|
metaId,
|
||||||
"metaId is required when passing arguments to create(...). To create an empty %s without"
|
() ->
|
||||||
|
String.format(
|
||||||
|
"metaId is required when passing arguments to create(...)."
|
||||||
|
+ " To create an empty %s without"
|
||||||
+ " NoteDb data, use empty(...) instead",
|
+ " NoteDb data, use empty(...) instead",
|
||||||
ChangeNotesState.class.getSimpleName());
|
ChangeNotesState.class.getSimpleName()));
|
||||||
return builder()
|
return builder()
|
||||||
.metaId(metaId)
|
.metaId(metaId)
|
||||||
.changeId(changeId)
|
.changeId(changeId)
|
||||||
@ -303,7 +306,7 @@ public abstract class ChangeNotesState {
|
|||||||
abstract Timestamp readOnlyUntil();
|
abstract Timestamp readOnlyUntil();
|
||||||
|
|
||||||
Change newChange(Project.NameKey project) {
|
Change newChange(Project.NameKey project) {
|
||||||
ChangeColumns c = checkNotNull(columns(), "columns are required");
|
ChangeColumns c = requireNonNull(columns(), "columns are required");
|
||||||
Change change =
|
Change change =
|
||||||
new Change(
|
new Change(
|
||||||
c.changeKey(),
|
c.changeKey(),
|
||||||
@ -351,7 +354,7 @@ public abstract class ChangeNotesState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void copyNonConstructorColumnsTo(Change change) {
|
private void copyNonConstructorColumnsTo(Change change) {
|
||||||
ChangeColumns c = checkNotNull(columns(), "columns are required");
|
ChangeColumns c = requireNonNull(columns(), "columns are required");
|
||||||
if (c.status() != null) {
|
if (c.status() != null) {
|
||||||
change.setStatus(c.status());
|
change.setStatus(c.status());
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ package com.google.gerrit.server.notedb;
|
|||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_ASSIGNEE;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_ASSIGNEE;
|
||||||
@ -42,6 +41,7 @@ import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_TOPIC;
|
|||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_WORK_IN_PROGRESS;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbUtil.sanitizeFooter;
|
import static com.google.gerrit.server.notedb.NoteDbUtil.sanitizeFooter;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -501,7 +501,7 @@ public class ChangeUpdate extends AbstractChangeUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setGroups(List<String> groups) {
|
public void setGroups(List<String> groups) {
|
||||||
checkNotNull(groups, "groups may not be null");
|
requireNonNull(groups, "groups may not be null");
|
||||||
this.groups = groups;
|
this.groups = groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.refsDraftComments;
|
import static com.google.gerrit.reviewdb.client.RefNames.refsDraftComments;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.ImmutableListMultimap;
|
import com.google.common.collect.ImmutableListMultimap;
|
||||||
@ -184,7 +184,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
|||||||
@Override
|
@Override
|
||||||
protected LoadHandle openHandle(Repository repo) throws NoSuchChangeException, IOException {
|
protected LoadHandle openHandle(Repository repo) throws NoSuchChangeException, IOException {
|
||||||
if (rebuildResult != null) {
|
if (rebuildResult != null) {
|
||||||
StagedResult sr = checkNotNull(rebuildResult.staged());
|
StagedResult sr = requireNonNull(rebuildResult.staged());
|
||||||
return LoadHandle.create(
|
return LoadHandle.create(
|
||||||
ChangeNotesCommit.newStagedRevWalk(repo, sr.allUsersObjects()),
|
ChangeNotesCommit.newStagedRevWalk(repo, sr.allUsersObjects()),
|
||||||
findNewId(sr.allUsersCommands(), getRefName()));
|
findNewId(sr.allUsersCommands(), getRefName()));
|
||||||
@ -229,7 +229,7 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
|||||||
logger.atFine().log(
|
logger.atFine().log(
|
||||||
"Rebuilding change %s via drafts failed: %s", getChangeId(), e.getMessage());
|
"Rebuilding change %s via drafts failed: %s", getChangeId(), e.getMessage());
|
||||||
args.metrics.autoRebuildFailureCount.increment(CHANGES);
|
args.metrics.autoRebuildFailureCount.increment(CHANGES);
|
||||||
checkNotNull(r.staged());
|
requireNonNull(r.staged());
|
||||||
return LoadHandle.create(
|
return LoadHandle.create(
|
||||||
ChangeNotesCommit.newStagedRevWalk(repo, r.staged().allUsersObjects()), draftsId(r));
|
ChangeNotesCommit.newStagedRevWalk(repo, r.staged().allUsersObjects()), draftsId(r));
|
||||||
}
|
}
|
||||||
@ -249,8 +249,8 @@ public class DraftCommentNotes extends AbstractChangeNotes<DraftCommentNotes> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ObjectId draftsId(NoteDbUpdateManager.Result r) {
|
private ObjectId draftsId(NoteDbUpdateManager.Result r) {
|
||||||
checkNotNull(r);
|
requireNonNull(r);
|
||||||
checkNotNull(r.newState());
|
requireNonNull(r.newState());
|
||||||
return r.newState().getDraftIds().get(author);
|
return r.newState().getDraftIds().get(author);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,12 +15,12 @@
|
|||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.refsDraftComments;
|
import static com.google.gerrit.reviewdb.client.RefNames.refsDraftComments;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage.NOTE_DB;
|
import static com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage.NOTE_DB;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage.REVIEW_DB;
|
import static com.google.gerrit.server.notedb.NoteDbChangeState.PrimaryStorage.REVIEW_DB;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
@ -339,10 +339,10 @@ public class NoteDbChangeState {
|
|||||||
PrimaryStorage primaryStorage,
|
PrimaryStorage primaryStorage,
|
||||||
Optional<RefState> refState,
|
Optional<RefState> refState,
|
||||||
Optional<Timestamp> readOnlyUntil) {
|
Optional<Timestamp> readOnlyUntil) {
|
||||||
this.changeId = checkNotNull(changeId);
|
this.changeId = requireNonNull(changeId);
|
||||||
this.primaryStorage = checkNotNull(primaryStorage);
|
this.primaryStorage = requireNonNull(primaryStorage);
|
||||||
this.refState = checkNotNull(refState);
|
this.refState = requireNonNull(refState);
|
||||||
this.readOnlyUntil = checkNotNull(readOnlyUntil);
|
this.readOnlyUntil = requireNonNull(readOnlyUntil);
|
||||||
|
|
||||||
switch (primaryStorage) {
|
switch (primaryStorage) {
|
||||||
case REVIEW_DB:
|
case REVIEW_DB:
|
||||||
|
@ -16,10 +16,10 @@ package com.google.gerrit.server.notedb;
|
|||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_DRAFT_COMMENTS;
|
import static com.google.gerrit.reviewdb.client.RefNames.REFS_DRAFT_COMMENTS;
|
||||||
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
import static com.google.gerrit.server.notedb.NoteDbTable.CHANGES;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.auto.value.AutoValue;
|
import com.google.auto.value.AutoValue;
|
||||||
import com.google.common.collect.HashBasedTable;
|
import com.google.common.collect.HashBasedTable;
|
||||||
@ -186,7 +186,7 @@ public class NoteDbUpdateManager implements AutoCloseable {
|
|||||||
"expected reader to be created from %s, but was %s",
|
"expected reader to be created from %s, but was %s",
|
||||||
ins,
|
ins,
|
||||||
reader.getCreatedFromInserter());
|
reader.getCreatedFromInserter());
|
||||||
this.repo = checkNotNull(repo);
|
this.repo = requireNonNull(repo);
|
||||||
|
|
||||||
if (saveObjects) {
|
if (saveObjects) {
|
||||||
this.inMemIns = new InMemoryInserter(rw.getObjectReader());
|
this.inMemIns = new InMemoryInserter(rw.getObjectReader());
|
||||||
@ -199,7 +199,7 @@ public class NoteDbUpdateManager implements AutoCloseable {
|
|||||||
|
|
||||||
this.rw = new RevWalk(tempIns.newReader());
|
this.rw = new RevWalk(tempIns.newReader());
|
||||||
this.finalIns = ins;
|
this.finalIns = ins;
|
||||||
this.cmds = checkNotNull(cmds);
|
this.cmds = requireNonNull(cmds);
|
||||||
this.close = close;
|
this.close = close;
|
||||||
this.saveObjects = saveObjects;
|
this.saveObjects = saveObjects;
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
package com.google.gerrit.server.notedb;
|
package com.google.gerrit.server.notedb;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS;
|
import static com.google.gerrit.reviewdb.client.RefNames.REFS;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.REFS_SEQUENCES;
|
import static com.google.gerrit.reviewdb.client.RefNames.REFS_SEQUENCES;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
import static org.eclipse.jgit.lib.Constants.OBJ_BLOB;
|
||||||
|
|
||||||
import com.github.rholder.retry.RetryException;
|
import com.github.rholder.retry.RetryException;
|
||||||
@ -167,9 +167,9 @@ public class RepoSequence {
|
|||||||
Runnable afterReadRef,
|
Runnable afterReadRef,
|
||||||
Retryer<RefUpdate.Result> retryer,
|
Retryer<RefUpdate.Result> retryer,
|
||||||
int floor) {
|
int floor) {
|
||||||
this.repoManager = checkNotNull(repoManager, "repoManager");
|
this.repoManager = requireNonNull(repoManager, "repoManager");
|
||||||
this.gitRefUpdated = checkNotNull(gitRefUpdated, "gitRefUpdated");
|
this.gitRefUpdated = requireNonNull(gitRefUpdated, "gitRefUpdated");
|
||||||
this.projectName = checkNotNull(projectName, "projectName");
|
this.projectName = requireNonNull(projectName, "projectName");
|
||||||
|
|
||||||
checkArgument(
|
checkArgument(
|
||||||
name != null
|
name != null
|
||||||
@ -179,13 +179,13 @@ public class RepoSequence {
|
|||||||
name);
|
name);
|
||||||
this.refName = RefNames.REFS_SEQUENCES + name;
|
this.refName = RefNames.REFS_SEQUENCES + name;
|
||||||
|
|
||||||
this.seed = checkNotNull(seed, "seed");
|
this.seed = requireNonNull(seed, "seed");
|
||||||
this.floor = floor;
|
this.floor = floor;
|
||||||
|
|
||||||
checkArgument(batchSize > 0, "expected batchSize > 0, got: %s", batchSize);
|
checkArgument(batchSize > 0, "expected batchSize > 0, got: %s", batchSize);
|
||||||
this.batchSize = batchSize;
|
this.batchSize = batchSize;
|
||||||
this.afterReadRef = checkNotNull(afterReadRef, "afterReadRef");
|
this.afterReadRef = requireNonNull(afterReadRef, "afterReadRef");
|
||||||
this.retryer = checkNotNull(retryer, "retryer");
|
this.retryer = requireNonNull(retryer, "retryer");
|
||||||
|
|
||||||
counterLock = new ReentrantLock(true);
|
counterLock = new ReentrantLock(true);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,11 @@
|
|||||||
package com.google.gerrit.server.notedb.rebuild;
|
package com.google.gerrit.server.notedb.rebuild;
|
||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
import static com.google.gerrit.reviewdb.client.RefNames.changeMetaRef;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_HASHTAGS;
|
||||||
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET;
|
import static com.google.gerrit.server.notedb.ChangeNoteUtil.FOOTER_PATCH_SET;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
|
|||||||
changeId, bundleReader.fromReviewDb(db, changeId)));
|
changeId, bundleReader.fromReviewDb(db, changeId)));
|
||||||
}
|
}
|
||||||
NoteDbChangeState newNoteDbState =
|
NoteDbChangeState newNoteDbState =
|
||||||
checkNotNull(NoteDbChangeState.parse(changeId, newNoteDbStateStr));
|
requireNonNull(NoteDbChangeState.parse(changeId, newNoteDbStateStr));
|
||||||
try {
|
try {
|
||||||
db.changes()
|
db.changes()
|
||||||
.atomicUpdate(
|
.atomicUpdate(
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
package com.google.gerrit.server.notedb.rebuild;
|
package com.google.gerrit.server.notedb.rebuild;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
@ -103,7 +103,7 @@ class EventList<E extends Event> implements Iterable<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PatchSet.Id getPatchSetId() {
|
PatchSet.Id getPatchSetId() {
|
||||||
PatchSet.Id id = checkNotNull(get(0).psId);
|
PatchSet.Id id = requireNonNull(get(0).psId);
|
||||||
for (int i = 1; i < size(); i++) {
|
for (int i = 1; i < size(); i++) {
|
||||||
checkState(
|
checkState(
|
||||||
get(i).psId.equals(id), "mismatched patch sets in EventList: %s != %s", id, get(i).psId);
|
get(i).psId.equals(id), "mismatched patch sets in EventList: %s != %s", id, get(i).psId);
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.notedb.rebuild;
|
package com.google.gerrit.server.notedb.rebuild;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_GC_SECTION;
|
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_GC_SECTION;
|
||||||
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_AUTO;
|
import static org.eclipse.jgit.lib.ConfigConstants.CONFIG_KEY_AUTO;
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class GcAllUsers {
|
|||||||
|
|
||||||
public void run(PrintWriter writer) {
|
public void run(PrintWriter writer) {
|
||||||
// Print both log messages and progress to given writer.
|
// Print both log messages and progress to given writer.
|
||||||
run(checkNotNull(writer)::println, writer);
|
run(requireNonNull(writer)::println, writer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(Consumer<String> logOneLine, @Nullable PrintWriter progressWriter) {
|
private void run(Consumer<String> logOneLine, @Nullable PrintWriter progressWriter) {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package com.google.gerrit.server.notedb.rebuild;
|
package com.google.gerrit.server.notedb.rebuild;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.unwrapDb;
|
import static com.google.gerrit.reviewdb.server.ReviewDbUtil.unwrapDb;
|
||||||
import static com.google.gerrit.server.notedb.NotesMigration.SECTION_NOTE_DB;
|
import static com.google.gerrit.server.notedb.NotesMigration.SECTION_NOTE_DB;
|
||||||
@ -26,6 +25,7 @@ import static com.google.gerrit.server.notedb.NotesMigrationState.READ_WRITE_WIT
|
|||||||
import static com.google.gerrit.server.notedb.NotesMigrationState.WRITE;
|
import static com.google.gerrit.server.notedb.NotesMigrationState.WRITE;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.stream.Collectors.joining;
|
import static java.util.stream.Collectors.joining;
|
||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ public class NoteDbMigrator implements AutoCloseable {
|
|||||||
* @return this.
|
* @return this.
|
||||||
*/
|
*/
|
||||||
public Builder setProgressOut(OutputStream progressOut) {
|
public Builder setProgressOut(OutputStream progressOut) {
|
||||||
this.progressOut = checkNotNull(progressOut);
|
this.progressOut = requireNonNull(progressOut);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.patch;
|
package com.google.gerrit.server.patch;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
import static com.google.gerrit.server.ioutil.BasicSerialization.readVarInt32;
|
import static com.google.gerrit.server.ioutil.BasicSerialization.readVarInt32;
|
||||||
import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
|
import static com.google.gerrit.server.ioutil.BasicSerialization.writeVarInt32;
|
||||||
|
import static java.util.Objects.requireNonNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -59,7 +59,7 @@ public class ComparisonType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getParentNum() {
|
public int getParentNum() {
|
||||||
checkNotNull(parentNum);
|
requireNonNull(parentNum);
|
||||||
return parentNum;
|
return parentNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user