Merge changes from topic 'checkstyle-cleanup'

* changes:
  Remove redundant 'private' modifier on constructors
  Remove redundant 'static' modifiers
  InitIndex: Add comment in empty if-block
  Declare variables on separate lines
  Change class modifier order to follow Java Language Spec
  Add missing whitespace around keywords, operators and braces
This commit is contained in:
David Pursehouse
2016-04-12 00:19:02 +00:00
committed by Gerrit Code Review
178 changed files with 239 additions and 231 deletions

View File

@@ -29,15 +29,15 @@ public class UseGerritConfigAnnotationTest extends AbstractDaemonTest {
Config serverConfig;
@Test
@GerritConfig(name="x.y", value="z")
@GerritConfig(name = "x.y", value = "z")
public void testOne() {
assertThat(serverConfig.getString("x", null, "y")).isEqualTo("z");
}
@Test
@GerritConfigs({
@GerritConfig(name="x.y", value="z"),
@GerritConfig(name="a.b", value="c")
@GerritConfig(name = "x.y", value = "z"),
@GerritConfig(name = "a.b", value = "c")
})
public void testMultiple() {
assertThat(serverConfig.getString("x", null, "y")).isEqualTo("z");

View File

@@ -103,7 +103,7 @@ public class ConfigChangeIT extends AbstractDaemonTest {
assertThat(e).hasMessage(
"Failed to submit 1 change due to the following problems:\n"
+ "Change " + n + ": Change contains a project configuration that"
+" changes the parent project.\n"
+ " changes the parent project.\n"
+ "The change must be submitted by a Gerrit administrator.");
}

View File

@@ -490,7 +490,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements
private void touch(SqlHandle c, K key) throws SQLException {
if (c.touch == null) {
c.touch =c.conn.prepareStatement("UPDATE data SET accessed=? WHERE k=?");
c.touch = c.conn.prepareStatement("UPDATE data SET accessed=? WHERE k=?");
}
try {
c.touch.setTimestamp(1, TimeUtil.nowTs());

View File

@@ -39,7 +39,7 @@ public class GarbageCollectionResult {
}
public static class Error {
public static enum Type {
public enum Type {
/** Git garbage collection was already scheduled for this project */
GC_ALREADY_SCHEDULED,

View File

@@ -27,11 +27,11 @@ import org.eclipse.jgit.diff.Edit;
import java.util.List;
public class PatchScript {
public static enum DisplayMethod {
public enum DisplayMethod {
NONE, DIFF, IMG
}
public static enum FileMode {
public enum FileMode {
FILE, SYMLINK, GITLINK
}

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.common.data;
public class PermissionRule implements Comparable<PermissionRule> {
public static final String FORCE_PUSH = "Force Push";
public static final String FORCE_EDIT = "Force Edit";
public static enum Action {
public enum Action {
ALLOW, DENY, BLOCK,
INTERACTIVE, BATCH

View File

@@ -23,7 +23,7 @@ import java.util.Objects;
* Describes the state required to submit a change.
*/
public class SubmitRecord {
public static enum Status {
public enum Status {
/** The change is ready for submission. */
OK,
@@ -49,7 +49,7 @@ public class SubmitRecord {
public String errorMessage;
public static class Label {
public static enum Status {
public enum Status {
/**
* This label provides what is necessary for submission.
* <p>

View File

@@ -20,7 +20,7 @@ import com.google.gerrit.extensions.client.SubmitType;
* Describes the submit type for a change.
*/
public class SubmitTypeRecord {
public static enum Status {
public enum Status {
/** The type was computed successfully */
OK,

View File

@@ -66,7 +66,7 @@ public class ReviewInput {
*/
public String onBehalfOf;
public static enum DraftHandling {
public enum DraftHandling {
/** Delete pending drafts on this revision only. */
DELETE,
@@ -80,7 +80,7 @@ public class ReviewInput {
PUBLISH_ALL_REVISIONS
}
public static enum NotifyHandling {
public enum NotifyHandling {
NONE, OWNER, OWNER_REVIEWERS, ALL
}

View File

@@ -61,7 +61,7 @@ public interface Projects {
ListRequest list();
public abstract class ListRequest {
public static enum FilterType {
public enum FilterType {
CODE, PARENT_CANDIDATES, PERMISSIONS, ALL
}

View File

@@ -32,7 +32,7 @@ public class DiffPreferencesInfo {
public static final short[] CONTEXT_CHOICES =
{3, 10, 25, 50, 75, 100, WHOLE_FILE_CONTEXT};
public static enum Whitespace {
public enum Whitespace {
IGNORE_NONE,
IGNORE_TRAILING,
IGNORE_LEADING_AND_TRAILING,

View File

@@ -27,11 +27,11 @@ public class GeneralPreferencesInfo {
public static final int[] PAGESIZE_CHOICES = {10, 25, 50, 100};
/** Preferred method to download a change. */
public static enum DownloadCommand {
public enum DownloadCommand {
REPO_DOWNLOAD, PULL, CHECKOUT, CHERRY_PICK, FORMAT_PATCH
}
public static enum DateFormat {
public enum DateFormat {
/** US style dates: Apr 27, Feb 14, 2010 */
STD("MMM d", "MMM d, yyyy"),
@@ -64,7 +64,7 @@ public class GeneralPreferencesInfo {
}
}
public static enum ReviewCategoryStrategy {
public enum ReviewCategoryStrategy {
NONE,
NAME,
EMAIL,
@@ -72,18 +72,18 @@ public class GeneralPreferencesInfo {
ABBREV
}
public static enum DiffView {
public enum DiffView {
SIDE_BY_SIDE,
UNIFIED_DIFF
}
public static enum EmailStrategy {
public enum EmailStrategy {
ENABLED,
CC_ON_OWN_COMMENTS,
DISABLED
}
public static enum TimeFormat {
public enum TimeFormat {
/** 12-hour clock: 1:15 am, 2:13 pm */
HHMM_12("h:mm a"),

View File

@@ -19,7 +19,7 @@ public enum GerritTopMenu {
public final String menuName;
private GerritTopMenu() {
GerritTopMenu() {
menuName = name().substring(0, 1) + name().substring(1).toLowerCase();
}
}

View File

@@ -70,7 +70,7 @@ public enum ListChangesOption {
private final int value;
private ListChangesOption(int v) {
ListChangesOption(int v) {
this.value = v;
}

View File

@@ -26,7 +26,7 @@ public enum ListGroupsOption {
private final int value;
private ListGroupsOption(int v) {
ListGroupsOption(int v) {
this.value = v;
}

View File

@@ -35,7 +35,7 @@ public class DiffInfo {
// Binary file
public Boolean binary;
public static enum IntraLineStatus {
public enum IntraLineStatus {
OK,
TIMEOUT,
FAILURE

View File

@@ -15,7 +15,7 @@
package com.google.gerrit.extensions.common;
public class ProblemInfo {
public static enum Status {
public enum Status {
FIXED, FIX_FAILED
}

View File

@@ -18,7 +18,7 @@ import com.google.gerrit.extensions.annotations.ExtensionPoint;
import com.google.gerrit.extensions.common.WebLinkInfo;
@ExtensionPoint
public interface PatchSetWebLink extends WebLink{
public interface PatchSetWebLink extends WebLink {
/**
* {@link com.google.gerrit.extensions.common.WebLinkInfo}

View File

@@ -18,7 +18,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.Constants;
interface CopyableLabelText extends Constants {
static final CopyableLabelText I = GWT.create(CopyableLabelText.class);
final CopyableLabelText I = GWT.create(CopyableLabelText.class);
String tooltip();
String copied();

View File

@@ -102,7 +102,7 @@ class AttMap {
}
}
private static interface Tag {
private interface Tag {
void assertSafe(String name, String value);
}

View File

@@ -23,7 +23,7 @@ import com.google.gwt.user.client.ui.UIObject;
/** Displays custom tooltip message below an element. */
public class Tooltip {
interface Resources extends ClientBundle {
static final Resources I = GWT.create(Resources.class);
final Resources I = GWT.create(Resources.class);
@Source("tooltip.css")
Css css();

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.client.rpc;
import com.google.gwt.user.client.rpc.AsyncCallback;
/** Transforms a value and passes it on to another callback. */
public abstract class TransformCallback<I, O> implements AsyncCallback<I>{
public abstract class TransformCallback<I, O> implements AsyncCallback<I> {
private final AsyncCallback<O> callback;
protected TransformCallback(AsyncCallback<O> callback) {

View File

@@ -424,7 +424,7 @@ public class Dispatcher {
int line = 0;
int at = rest.lastIndexOf('@');
if (at > 0) {
String l = rest.substring(at+1);
String l = rest.substring(at + 1);
if (l.startsWith("a")) {
side = DisplaySide.A;
l = l.substring(1);

View File

@@ -936,7 +936,7 @@ public class Gerrit implements EntryPoint {
@Override
public void onKeyDown(KeyDownEvent event) {
if(event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
showHidePopup();
event.preventDefault();
}

View File

@@ -81,7 +81,7 @@ public abstract class SettingsScreen extends MenuScreen {
private void linkByPlugin(String pluginName, String text, String target) {
if (ambiguousMenuNames.contains(text)) {
text += " ("+ pluginName + ")";
text += " (" + pluginName + ")";
}
link(text, target);
}

View File

@@ -211,7 +211,9 @@ public class AccountGroupInfoScreen extends AccountGroupScreen {
protected void display(final GroupInfo group, final boolean canModify) {
groupUUIDLabel.setText(group.getGroupUUID().get());
groupNameTxt.setText(group.name());
ownerTxt.setText(group.owner() != null?group.owner():Util.M.deletedReference(group.getOwnerUUID().get()));
ownerTxt.setText(group.owner() != null
? group.owner()
: Util.M.deletedReference(group.getOwnerUUID().get()));
descTxt.setText(group.description());
visibleToAllCheckBox.setValue(group.options().isVisibleToAll());
setMembersTabVisible(AccountGroup.isInternalGroup(group.getGroupUUID()));

View File

@@ -47,7 +47,7 @@ public class GroupReferenceBox extends Composite implements
toValue(event.getSelectedItem()));
}
});
suggestBox.addCloseHandler(new CloseHandler<RemoteSuggestBox>(){
suggestBox.addCloseHandler(new CloseHandler<RemoteSuggestBox>() {
@Override
public void onClose(CloseEvent<RemoteSuggestBox> event) {
suggestBox.setText("");

View File

@@ -113,7 +113,7 @@ public class GroupTable extends NavigationTable<GroupInfo> {
return a.name().compareTo(b.name());
}
});
for(GroupInfo group : list.subList(fromIndex, toIndex)) {
for (GroupInfo group : list.subList(fromIndex, toIndex)) {
final int row = table.getRowCount();
table.insertRow(row);
applyDataRowStyle(row);

View File

@@ -183,7 +183,7 @@ public class ProjectAccessScreen extends ProjectScreen {
driver.edit(mock);
}
@UiHandler(value={"cancel1", "cancel2"})
@UiHandler(value = {"cancel1", "cancel2"})
void onCancel(@SuppressWarnings("unused") ClickEvent event) {
Gerrit.display(PageLinks.toProjectAcceess(getProjectKey()));
}

View File

@@ -35,7 +35,7 @@ abstract class ActionMessageBox extends Composite {
interface Binder extends UiBinder<HTMLPanel, ActionMessageBox> {}
private static final Binder uiBinder = GWT.create(Binder.class);
static interface Style extends CssResource {
interface Style extends CssResource {
String popup();
}

View File

@@ -95,7 +95,7 @@ public class FileTable extends FlowPanel {
String restoreDelete();
}
public static enum Mode {
public enum Mode {
REVIEW,
EDIT
}

View File

@@ -132,7 +132,7 @@ public class Hashtags extends Composite {
ClickEvent.getType());
}
void init(ChangeScreen.Style style){
void init(ChangeScreen.Style style) {
this.style = style;
}
@@ -246,12 +246,12 @@ public class Hashtags extends Composite {
input.init(toJsArrayString(add), toJsArrayString(remove));
return input;
}
private static JsArrayString toJsArrayString(String commaSeparated){
private static JsArrayString toJsArrayString(String commaSeparated) {
if (commaSeparated == null || commaSeparated.equals("")) {
return null;
}
JsArrayString array = JsArrayString.createArray().cast();
for (String hashtag : commaSeparated.split(",")){
for (String hashtag : commaSeparated.split(",")) {
array.push(hashtag.trim());
}
return array;

View File

@@ -57,14 +57,14 @@ class LineComment extends Composite {
ps = defaultPs;
psLoc.removeFromParent();
psLoc = null;
psNum= null;
psNum = null;
} else {
ps = defaultPs;
sideLoc.removeFromParent();
sideLoc = null;
psLoc.removeFromParent();
psLoc = null;
psNum= null;
psNum = null;
}
if (info.hasLine()) {

View File

@@ -50,7 +50,7 @@ class Message extends Composite {
interface Binder extends UiBinder<HTMLPanel, Message> {}
private static final Binder uiBinder = GWT.create(Binder.class);
static interface Style extends CssResource {
interface Style extends CssResource {
String closed();
}

View File

@@ -137,7 +137,7 @@ public class RelatedChanges extends TabPanel {
abstract String getTitle(int count);
abstract String getTitle(String count);
private Tab(String defaultTitle, String tooltip) {
Tab(String defaultTitle, String tooltip) {
this.defaultTitle = defaultTitle;
this.tooltip = tooltip;
}

View File

@@ -20,8 +20,8 @@ import com.google.gwt.resources.client.CssResource;
public interface Resources extends ClientBundle {
public static final Resources I = GWT.create(Resources.class);
static final ChangeConstants C = GWT.create(ChangeConstants.class);
static final ChangeMessages M = GWT.create(ChangeMessages.class);
final ChangeConstants C = GWT.create(ChangeConstants.class);
final ChangeMessages M = GWT.create(ChangeMessages.class);
@Source("common.css") Style style();

View File

@@ -170,7 +170,7 @@ public class ChangeApi {
public static RestApi hashtags(int changeId) {
return change(changeId).view("hashtags");
}
public static RestApi hashtag(int changeId, String hashtag){
public static RestApi hashtag(int changeId, String hashtag) {
return change(changeId).view("hashtags").id(hashtag);
}

View File

@@ -493,7 +493,7 @@ public class ChangeTable extends NavigationTable<ChangeInfo> {
if (titleText != null) {
setTitleText(titleText);
return true;
} else if(titleWidget != null) {
} else if (titleWidget != null) {
setTitleWidget(titleWidget);
return true;
}

View File

@@ -19,11 +19,11 @@ import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.core.client.JsArray;
public class ReviewInput extends JavaScriptObject {
public static enum NotifyHandling {
public enum NotifyHandling {
NONE, OWNER, OWNER_REVIEWERS, ALL
}
public static enum DraftHandling {
public enum DraftHandling {
DELETE, PUBLISH, KEEP, PUBLISH_ALL_REVISIONS
}

View File

@@ -37,7 +37,7 @@ public class StarredChanges {
private static final Event.Type<ChangeStarHandler> TYPE = new Event.Type<>();
/** Handler that can receive notifications of a change's starred status. */
public static interface ChangeStarHandler {
public interface ChangeStarHandler {
void onChangeStar(ChangeStarEvent event);
}

View File

@@ -84,7 +84,7 @@ public class DashboardsTable extends NavigationTable<DashboardInfo> {
});
String ref = null;
for(DashboardInfo d : list) {
for (DashboardInfo d : list) {
if (!d.ref().equals(ref)) {
ref = d.ref();
insertTitleRow(table.getRowCount(), ref);

View File

@@ -68,7 +68,7 @@ public class Header extends Composite {
Resources.I.style().ensureInjected();
}
private static enum ReviewedState {
private enum ReviewedState {
AUTO_REVIEW, LOADED
}

View File

@@ -46,7 +46,7 @@ class PublishedBox extends CommentBox {
interface Binder extends UiBinder<HTMLPanel, PublishedBox> {}
private static final Binder uiBinder = GWT.create(Binder.class);
static interface Style extends CssResource {
interface Style extends CssResource {
String closed();
}

View File

@@ -20,7 +20,7 @@ import com.google.gwt.resources.client.ImageResource;
/** Resources used by diff. */
interface Resources extends ClientBundle {
static final Resources I = GWT.create(Resources.class);
final Resources I = GWT.create(Resources.class);
@Source("CommentBox.css") CommentBox.Style style();
@Source("Scrollbar.css") Scrollbar.Style scrollbarStyle();

View File

@@ -357,7 +357,8 @@ class SideBySideCommentManager extends CommentManager {
return w;
}
int lineA, lineB;
int lineA;
int lineB;
if (line == 0) {
lineA = lineB = 0;
} else if (side == DisplaySide.A) {

View File

@@ -44,9 +44,9 @@ class SideBySideSkipBar extends SkipBar {
String noExpand();
}
@UiField(provided=true) Anchor skipNum;
@UiField(provided=true) Anchor upArrow;
@UiField(provided=true) Anchor downArrow;
@UiField(provided = true) Anchor skipNum;
@UiField(provided = true) Anchor upArrow;
@UiField(provided = true) Anchor downArrow;
@UiField SkipBarStyle style;
private final SideBySideSkipManager manager;

View File

@@ -44,9 +44,9 @@ class UnifiedSkipBar extends SkipBar {
String noExpand();
}
@UiField(provided=true) Anchor skipNum;
@UiField(provided=true) Anchor upArrow;
@UiField(provided=true) Anchor downArrow;
@UiField(provided = true) Anchor skipNum;
@UiField(provided = true) Anchor upArrow;
@UiField(provided = true) Anchor downArrow;
@UiField SkipBarStyle style;
private final UnifiedSkipManager manager;

View File

@@ -18,7 +18,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.Constants;
interface EditConstants extends Constants {
static final EditConstants I = GWT.create(EditConstants.class);
final EditConstants I = GWT.create(EditConstants.class);
String closeUnsavedChanges();
String cancelUnsavedChanges();

View File

@@ -81,7 +81,7 @@ public class MorphingTabPanel extends TabPanel {
/* Re-insert the widget right after the first visible widget found
when scanning backwards from the current widget */
for (int pos = origPos -1; pos >=0 ; pos--) {
for (int pos = origPos - 1; pos >= 0 ; pos--) {
int visiblePos = visibles.indexOf(widgets.get(pos));
if (visiblePos != -1) {
visibles.add(visiblePos + 1, w);

View File

@@ -70,7 +70,7 @@ public abstract class Screen extends View {
public void registerKeys() {
}
private static enum Cols {
private enum Cols {
West, Title, East, FarEast
}

View File

@@ -36,7 +36,7 @@ public class ScreenLoadEvent extends GwtEvent<ScreenLoadHandler> {
return TYPE;
}
public Screen getScreen(){
public Screen getScreen() {
return screen;
}
}

View File

@@ -21,7 +21,7 @@ import com.google.gwt.resources.client.DataResource.DoNotEmbed;
import com.google.gwt.resources.client.ExternalTextResource;
interface Lib extends ClientBundle {
static final Lib I = GWT.create(Lib.class);
final Lib I = GWT.create(Lib.class);
@Source("cm.css")
ExternalTextResource css();

View File

@@ -60,7 +60,7 @@ public class GitOverHttpModule extends ServletModule {
filter("/a/*").through(authFilter);
}
private boolean isHttpEnabled(){
private boolean isHttpEnabled() {
return downloadConfig.getDownloadSchemes().contains(CoreDownloadSchemes.ANON_HTTP)
|| downloadConfig.getDownloadSchemes().contains(CoreDownloadSchemes.HTTP);
}

View File

@@ -23,7 +23,7 @@ import javax.servlet.http.HttpServletRequest;
public class LoginUrlToken {
private static final String DEFAULT_TOKEN = '#' + PageLinks.MINE;
public static String getToken(final HttpServletRequest req){
public static String getToken(final HttpServletRequest req) {
String token = req.getPathInfo();
if (Strings.isNullOrEmpty(token)) {
return DEFAULT_TOKEN;

View File

@@ -221,7 +221,7 @@ class ProjectOAuthFilter implements Filter {
throw new ServletException("OAuth login provider configuration is"
+ " invalid: Must be of the form pluginName:providerName");
}
defaultAuthPlugin= gitOAuthProvider.substring(0, splitPos);
defaultAuthPlugin = gitOAuthProvider.substring(0, splitPos);
defaultAuthProvider = gitOAuthProvider.substring(splitPos + 1);
OAuthLoginProvider provider = loginProviders.get(defaultAuthPlugin,
defaultAuthProvider);

View File

@@ -157,7 +157,7 @@ class HttpAuthFilter implements Filter {
}
String getRemoteExternalIdToken(HttpServletRequest req) {
if(externalIdHeader != null) {
if (externalIdHeader != null) {
return emptyToNull(req.getHeader(externalIdHeader));
} else {
return null;

View File

@@ -125,7 +125,7 @@ class HttpPluginServlet extends HttpServlet
int c = host.lastIndexOf(':');
if (0 <= c) {
sshHost = host.substring(0, c);
sshPort = Integer.parseInt(host.substring(c+1));
sshPort = Integer.parseInt(host.substring(c + 1));
} else {
sshHost = host;
sshPort = 22;
@@ -346,7 +346,7 @@ class HttpPluginServlet extends HttpServlet
int nameOffset) throws IOException {
if (!entries.isEmpty()) {
md.append("## ").append(sectionTitle).append(" ##\n");
for(PluginEntry entry : entries) {
for (PluginEntry entry : entries) {
String rsrc = entry.getName().substring(prefix.length());
String entryTitle;
if (rsrc.endsWith(".html")) {

View File

@@ -208,7 +208,7 @@ class PluginServletContext {
}
}
static interface API {
interface API {
String getContextPath();
String getInitParameter(String name);
@SuppressWarnings("rawtypes")

View File

@@ -19,7 +19,7 @@ import com.google.common.cache.Cache;
import java.nio.file.Path;
/** Serve a single static file, regardless of path. */
class SingleFileServlet extends ResourceServlet{
class SingleFileServlet extends ResourceServlet {
private static final long serialVersionUID = 1L;
private final Path path;

View File

@@ -796,7 +796,7 @@ public class RestApiServlet extends HttpServlet {
final BinaryResult src) throws IOException {
TemporaryBuffer.Heap buf = heap(HEAP_EST_SIZE, Integer.MAX_VALUE);
buf.write(JSON_MAGIC);
try(Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
try (Writer w = new BufferedWriter(new OutputStreamWriter(buf, UTF_8));
JsonWriter json = new JsonWriter(w)) {
json.setLenient(true);
json.setHtmlSafe(true);

View File

@@ -121,7 +121,7 @@ public class BaseServiceImplementation {
}
/** Arbitrary action to run with a database connection. */
public static interface Action<T> {
public interface Action<T> {
/**
* Perform this action, returning the onSuccess value.
*

View File

@@ -74,7 +74,7 @@ class AccountServiceImpl extends BaseServiceImplementation implements
@Override
public void changeDiffPreferences(final DiffPreferencesInfo diffPref,
AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>(){
run(callback, new Action<VoidResult>() {
@Override
public VoidResult run(ReviewDb db) throws OrmException {
if (!getUser().isIdentifiedUser()) {

View File

@@ -143,7 +143,8 @@ final class WrappableSearcherManager extends ReferenceManager<IndexSearcher> {
@Override
protected IndexSearcher refreshIfNeeded(IndexSearcher referenceToRefresh) throws IOException {
final IndexReader r = referenceToRefresh.getIndexReader();
assert r instanceof DirectoryReader: "searcher's IndexReader should be a DirectoryReader, but got " + r;
assert r instanceof DirectoryReader :
"searcher's IndexReader should be a DirectoryReader, but got " + r;
final IndexReader newReader = DirectoryReader.openIfChanged((DirectoryReader) r);
if (newReader == null) {
return null;
@@ -171,7 +172,8 @@ final class WrappableSearcherManager extends ReferenceManager<IndexSearcher> {
final IndexSearcher searcher = acquire();
try {
final IndexReader r = searcher.getIndexReader();
assert r instanceof DirectoryReader: "searcher's IndexReader should be a DirectoryReader, but got " + r;
assert r instanceof DirectoryReader :
"searcher's IndexReader should be a DirectoryReader, but got " + r;
return ((DirectoryReader) r).isCurrent();
} finally {
release(searcher);

View File

@@ -17,7 +17,7 @@ package com.google.gerrit.httpd.auth.openid;
import java.util.Map;
final class DiscoveryResult {
static enum Status {
enum Status {
/** Provider was discovered and {@code providerUrl} is valid. */
VALID,

View File

@@ -218,7 +218,7 @@ class LoginForm extends HttpServlet {
url.append(r.providerUrl);
if (r.providerArgs != null && !r.providerArgs.isEmpty()) {
boolean first = true;
for(Map.Entry<String, String> arg : r.providerArgs.entrySet()) {
for (Map.Entry<String, String> arg : r.providerArgs.entrySet()) {
if (first) {
url.append('?');
first = false;

View File

@@ -165,7 +165,7 @@ public class AuthSMTPClient extends SMTPClient {
}
String cmd = encodeBase64(smtpUser.getBytes(UTF_8));
if(sendCommand(cmd) != 334) {
if (sendCommand(cmd) != 334) {
return false;
}

View File

@@ -116,7 +116,7 @@ public class LocalUsernamesToLowerCase extends SiteProgram {
private class Worker extends Thread {
@Override
public void run() {
try (ReviewDb db = database.open()){
try (ReviewDb db = database.open()) {
for (;;) {
final AccountExternalId extId = next();
if (extId == null) {

View File

@@ -159,7 +159,7 @@ public class Reindex extends SiteProgram {
int n = result.doneCount() + result.failedCount();
double t = result.elapsed(TimeUnit.MILLISECONDS) / 1000d;
System.out.format("Reindexed %d documents in %s index in %.01fs (%.01f/s)\n",
n, def.getName(), t, n/t);
n, def.getName(), t, n / t);
if (result.success()) {
index.markReady(true);
}

View File

@@ -64,6 +64,7 @@ class InitIndex implements InitStep {
site, def.getLatest().getVersion(), true);
}
if ((site.isNew || isEmptySite()) && type == IndexType.LUCENE) {
// Do nothing
} else {
final String message = String.format(
"\nThe index must be %sbuilt before starting Gerrit:\n"

View File

@@ -68,10 +68,11 @@ public class InitPlugins implements InitStep {
}
});
return FluentIterable.from(result).toSortedList(new Comparator<PluginData>() {
@Override
public int compare(PluginData a, PluginData b) {
return a.name.compareTo(b.name);
}});
@Override
public int compare(PluginData a, PluginData b) {
return a.name.compareTo(b.name);
}
});
}
private final ConsoleUI ui;

View File

@@ -180,7 +180,7 @@ public class AllProjectsConfig extends VersionedMetaData {
ru.setExpectedOldObjectId(revision);
ru.setRefLogMessage(refLogMsg, false);
RefUpdate.Result r = ru.update();
switch(r) {
switch (r) {
case FAST_FORWARD:
case NEW:
case NO_CHANGE:

View File

@@ -66,7 +66,7 @@ public class PrologCompiler implements Callable<PrologCompiler.Status> {
PrologCompiler create(Repository git);
}
public static enum Status {
public enum Status {
NO_RULES, COMPILED
}

View File

@@ -59,7 +59,7 @@ import java.sql.Timestamp;
* </ul>
*/
public final class Account {
public static enum FieldName {
public enum FieldName {
FULL_NAME, USER_NAME, REGISTER_NEW_EMAIL
}

View File

@@ -281,7 +281,7 @@ public final class Change {
* codes ('A'..'Z') indicate a change that is closed and cannot be further
* modified.
* */
public static enum Status {
public enum Status {
/**
* Change is open and pending review, or review is in progress.
*
@@ -356,7 +356,7 @@ public final class Change {
private final boolean closed;
private final ChangeStatus changeStatus;
private Status(char c, ChangeStatus cs) {
Status(char c, ChangeStatus cs) {
code = c;
closed = !(MIN_OPEN <= c && c <= MAX_OPEN);
changeStatus = cs;

View File

@@ -68,7 +68,7 @@ public final class Patch {
}
/** Type of modification made to the file path. */
public static enum ChangeType implements CodedEnum {
public enum ChangeType implements CodedEnum {
/** Path is being created/introduced by this patch. */
ADDED('A'),
@@ -89,7 +89,7 @@ public final class Patch {
private final char code;
private ChangeType(final char c) {
ChangeType(final char c) {
code = c;
}
@@ -113,7 +113,7 @@ public final class Patch {
}
/** Type of formatting for this patch. */
public static enum PatchType implements CodedEnum {
public enum PatchType implements CodedEnum {
/**
* A textual difference between two versions.
*
@@ -148,7 +148,7 @@ public final class Patch {
private final char code;
private PatchType(final char c) {
PatchType(final char c) {
code = c;
}

View File

@@ -60,14 +60,14 @@ public final class PatchLineComment {
public static final char STATUS_DRAFT = 'd';
public static final char STATUS_PUBLISHED = 'P';
public static enum Status {
public enum Status {
DRAFT(STATUS_DRAFT),
PUBLISHED(STATUS_PUBLISHED);
private final char code;
private Status(final char c) {
Status(final char c) {
code = c;
}

View File

@@ -24,7 +24,7 @@ import com.google.gwtorm.client.StringKey;
public final class Project {
/** Project name key */
public static class NameKey extends
StringKey<com.google.gwtorm.client.Key<?>>{
StringKey<com.google.gwtorm.client.Key<?>> {
private static final long serialVersionUID = 1L;
@Column(id = 1)

View File

@@ -44,7 +44,7 @@ public class Description {
}
}
public static enum FieldOrdering {
public enum FieldOrdering {
/** Default ordering places fields at end of the parent metric name. */
AT_END,

View File

@@ -54,7 +54,7 @@ public class PrologEnvironment extends BufferingPrologControl {
private static final Logger log =
LoggerFactory.getLogger(PrologEnvironment.class);
public static interface Factory {
public interface Factory {
/**
* Construct a new Prolog interpreter.
*

View File

@@ -44,7 +44,7 @@ public class WebLinks {
@Override
public boolean apply(WebLinkInfo link) {
if (link == null){
if (link == null) {
return false;
} else if (Strings.isNullOrEmpty(link.name)
|| Strings.isNullOrEmpty(link.url)) {

View File

@@ -354,7 +354,7 @@ public class AccountManager {
}
try {
update(db, who, extId);
} catch(NameAlreadyUsedException | InvalidUserNameException e) {
} catch (NameAlreadyUsedException | InvalidUserNameException e) {
throw new AccountException("Account update failed", e);
}

View File

@@ -35,7 +35,7 @@ import com.google.inject.Singleton;
@Singleton
public class AccountsCollection implements
RestCollection<TopLevelResource, AccountResource>,
AcceptsCreate<TopLevelResource>{
AcceptsCreate<TopLevelResource> {
private final Provider<CurrentUser> self;
private final AccountResolver resolver;
private final AccountControl.Factory accountControlFactory;

View File

@@ -39,7 +39,7 @@ import java.util.Map;
/** Access control management for server-wide capabilities. */
public class CapabilityControl {
public static interface Factory {
public interface Factory {
CapabilityControl create(CurrentUser user);
}

View File

@@ -66,7 +66,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, Input> {
public List<String> groups;
}
public static interface Factory {
public interface Factory {
CreateAccount create(String username);
}

View File

@@ -42,7 +42,7 @@ import org.slf4j.LoggerFactory;
public class CreateEmail implements RestModifyView<AccountResource, EmailInput> {
private static final Logger log = LoggerFactory.getLogger(CreateEmail.class);
public static interface Factory {
public interface Factory {
CreateEmail create(String email);
}

View File

@@ -95,7 +95,7 @@ public class GroupCacheImpl implements GroupCache {
Optional<AccountGroup> g = byId.get(groupId);
return g.isPresent() ? g.get() : missing(groupId);
} catch (ExecutionException e) {
log.warn("Cannot load group "+groupId, e);
log.warn("Cannot load group " + groupId, e);
return missing(groupId);
}
}

View File

@@ -99,7 +99,7 @@ public class StarredChanges implements
@SuppressWarnings("unchecked")
@Override
public RestModifyView<AccountResource, EmptyInput> create(
AccountResource parent, IdString id) throws UnprocessableEntityException{
AccountResource parent, IdString id) throws UnprocessableEntityException {
try {
return createProvider.get()
.setChange(changes.parse(TopLevelResource.INSTANCE, id));

View File

@@ -31,7 +31,7 @@ public enum ArchiveFormat {
private final ArchiveCommand.Format<?> format;
private final String mimeType;
private ArchiveFormat(String mimeType, ArchiveCommand.Format<?> format) {
ArchiveFormat(String mimeType, ArchiveCommand.Format<?> format) {
this.format = format;
this.mimeType = mimeType;
ArchiveCommand.registerFormat(name(), format);

View File

@@ -403,7 +403,7 @@ public class ChangeEdits implements
rsrc.getChangeEdit(),
rsrc.getPath(),
input.content);
} catch(InvalidChangeOperationException | IOException e) {
} catch (InvalidChangeOperationException | IOException e) {
throw new ResourceConflictException(e.getMessage());
}
return Response.none();
@@ -434,7 +434,7 @@ public class ChangeEdits implements
throws AuthException, ResourceConflictException {
try {
editModifier.deleteFile(rsrc.getChangeEdit(), rsrc.getPath());
} catch(InvalidChangeOperationException | IOException e) {
} catch (InvalidChangeOperationException | IOException e) {
throw new ResourceConflictException(e.getMessage());
}
return Response.none();

View File

@@ -77,7 +77,7 @@ import java.util.Set;
import java.util.concurrent.ExecutorService;
public class ChangeInserter extends BatchUpdate.InsertChangeOp {
public static interface Factory {
public interface Factory {
ChangeInserter create(Change.Id cid, RevCommit rc, String refName);
}
@@ -406,7 +406,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
List<LabelType> labels = changeControl.getLabelTypes().getLabelTypes();
Map<String, Short> allApprovals = new HashMap<>();
Map<String, Short> oldApprovals = new HashMap<>();
for (LabelType lt : labels){
for (LabelType lt : labels) {
allApprovals.put(lt.getName(), (short) 0);
oldApprovals.put(lt.getName(), null);
}

View File

@@ -288,8 +288,8 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
public static class ChangeKindWeigher implements Weigher<Key, ChangeKind> {
@Override
public int weigh(Key key, ChangeKind changeKind) {
return 16 + 2*36 + 2*key.strategyName.length() // Size of Key, 64 bit JVM
+ 2*changeKind.name().length(); // Size of ChangeKind, 64 bit JVM
return 16 + 2 * 36 + 2 * key.strategyName.length() // Size of Key, 64 bit JVM
+ 2 * changeKind.name().length(); // Size of ChangeKind, 64 bit JVM
}
}

View File

@@ -164,8 +164,8 @@ public class GetDiff implements RestReadView<FileResource> {
case INSERT:
case REPLACE:
List<Edit> internalEdit = edit instanceof ReplaceEdit
? ((ReplaceEdit) edit).getInternalEdits()
: null;
? ((ReplaceEdit) edit).getInternalEdits()
: null;
content.addDiff(edit.getEndA(), edit.getEndB(), internalEdit);
break;
case EMPTY:
@@ -403,7 +403,7 @@ public class GetDiff implements RestReadView<FileResource> {
private final DiffPreferencesInfo.Whitespace whitespace;
private IgnoreWhitespace(DiffPreferencesInfo.Whitespace whitespace) {
IgnoreWhitespace(DiffPreferencesInfo.Whitespace whitespace) {
this.whitespace = whitespace;
}
}

View File

@@ -68,7 +68,7 @@ public class PatchSetInserter extends BatchUpdate.Op {
private static final Logger log =
LoggerFactory.getLogger(PatchSetInserter.class);
public static interface Factory {
public interface Factory {
PatchSetInserter create(RefControl refControl, PatchSet.Id psId,
RevCommit commit);
}

View File

@@ -81,7 +81,7 @@ public class RebaseUtil {
}
@AutoValue
static abstract class Base {
abstract static class Base {
private static Base create(ChangeControl ctl, PatchSet ps) {
if (ctl == null) {
return null;

View File

@@ -28,7 +28,7 @@ public class ReviewerResource implements RestResource {
public static final TypeLiteral<RestView<ReviewerResource>> REVIEWER_KIND =
new TypeLiteral<RestView<ReviewerResource>>() {};
public static interface Factory {
public interface Factory {
ReviewerResource create(ChangeResource change, Account.Id id);
}

View File

@@ -41,7 +41,7 @@ import java.util.TreeMap;
public class ListCaches implements RestReadView<ConfigResource> {
private final DynamicMap<Cache<?, ?>> cacheMap;
public static enum OutputFormat {
public enum OutputFormat {
LIST, TEXT_LIST
}

View File

@@ -52,7 +52,7 @@ public class PostCaches implements RestModifyView<ConfigResource, Input> {
}
}
public static enum Operation {
public enum Operation {
FLUSH_ALL, FLUSH
}

View File

@@ -82,7 +82,7 @@ import java.util.TimeZone;
@Singleton
public class ChangeEditModifier {
private static enum TreeOperation {
private enum TreeOperation {
CHANGE_ENTRY,
DELETE_ENTRY,
RENAME_ENTRY,

View File

@@ -147,7 +147,7 @@ public class ChangeEditUtil {
int n = change.currentPatchSetId().get();
String[] refNames = new String[n];
for (int i = n; i > 0; i--) {
refNames[i-1] = RefNames.refsEdit(
refNames[i - 1] = RefNames.refsEdit(
u.getAccountId(), change.getId(),
new PatchSet.Id(change.getId(), i));
}

View File

@@ -244,7 +244,7 @@ public class EventFactory {
SubmitLabelAttribute la = new SubmitLabelAttribute();
la.label = lbl.label;
la.status = lbl.status.name();
if(lbl.appliedBy != null) {
if (lbl.appliedBy != null) {
Account a = accountCache.get(lbl.appliedBy).getAccount();
la.by = asAccountAttribute(a);
}

Some files were not shown because too many files have changed in this diff Show More