Merge branch 'stable-2.15'
* stable-2.15: Make inner classes static where possible MigrateToNoteDb: Specify charset when constructing PrintWriter IndexServletTest: Specify charset in construction of String license-map: Fix deprecation warning Bazel: Make 'DefaultCharset' an ERROR when compiling with ErrorProne toolchain Specify charset when constructing PrintWriter Bazel: Change deprecated single file attribute parameter Bazel: Remove deprecated FileType Bazel: Replace PACKAGE_NAME constant with package_name() function Change-Id: Ibe9c2a13f3b0b4bc0ea6239c0158782a6de5b18e
This commit is contained in:
@@ -15,12 +15,14 @@
|
|||||||
package com.google.gerrit.index;
|
package com.google.gerrit.index;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Stopwatch;
|
import com.google.common.base.Stopwatch;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.common.util.concurrent.MoreExecutors;
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
@@ -64,7 +66,7 @@ public abstract class SiteIndexer<K, V, I extends Index<K, V>> {
|
|||||||
|
|
||||||
protected int totalWork = -1;
|
protected int totalWork = -1;
|
||||||
protected OutputStream progressOut = NullOutputStream.INSTANCE;
|
protected OutputStream progressOut = NullOutputStream.INSTANCE;
|
||||||
protected PrintWriter verboseWriter = new PrintWriter(NullOutputStream.INSTANCE);
|
protected PrintWriter verboseWriter = newPrintWriter(NullOutputStream.INSTANCE);
|
||||||
|
|
||||||
public void setTotalWork(int num) {
|
public void setTotalWork(int num) {
|
||||||
totalWork = num;
|
totalWork = num;
|
||||||
@@ -75,7 +77,7 @@ public abstract class SiteIndexer<K, V, I extends Index<K, V>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setVerboseOut(OutputStream out) {
|
public void setVerboseOut(OutputStream out) {
|
||||||
verboseWriter = new PrintWriter(checkNotNull(out));
|
verboseWriter = newPrintWriter(checkNotNull(out));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Result indexAll(I index);
|
public abstract Result indexAll(I index);
|
||||||
@@ -86,6 +88,10 @@ public abstract class SiteIndexer<K, V, I extends Index<K, V>> {
|
|||||||
new ErrorListener(future, desc, progress, ok), MoreExecutors.directExecutor());
|
new ErrorListener(future, desc, progress, ok), MoreExecutors.directExecutor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected PrintWriter newPrintWriter(OutputStream out) {
|
||||||
|
return new PrintWriter(new OutputStreamWriter(out, UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
private static class ErrorListener implements Runnable {
|
private static class ErrorListener implements Runnable {
|
||||||
private final ListenableFuture<?> future;
|
private final ListenableFuture<?> future;
|
||||||
private final String desc;
|
private final String desc;
|
||||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.pgm;
|
|||||||
|
|
||||||
import static com.google.common.base.MoreObjects.firstNonNull;
|
import static com.google.common.base.MoreObjects.firstNonNull;
|
||||||
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.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;
|
||||||
|
|
||||||
@@ -39,6 +40,7 @@ import com.google.gerrit.server.schema.DataSourceType;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -141,7 +143,7 @@ public class MigrateToNoteDb extends SiteProgram {
|
|||||||
migrator.migrate();
|
migrator.migrate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try (PrintWriter w = new PrintWriter(System.out, true)) {
|
try (PrintWriter w = new PrintWriter(new OutputStreamWriter(System.out, UTF_8), true)) {
|
||||||
gcAllUsers.run(w);
|
gcAllUsers.run(w);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@@ -30,7 +30,6 @@ import com.google.gerrit.server.index.IndexExecutor;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -60,7 +59,7 @@ public class AllAccountsIndexer extends SiteIndexer<Account.Id, AccountState, Ac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SiteIndexer.Result indexAll(AccountIndex index) {
|
public SiteIndexer.Result indexAll(AccountIndex index) {
|
||||||
ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
|
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
|
||||||
progress.start(2);
|
progress.start(2);
|
||||||
Stopwatch sw = Stopwatch.createStarted();
|
Stopwatch sw = Stopwatch.createStarted();
|
||||||
List<Account.Id> ids;
|
List<Account.Id> ids;
|
||||||
|
@@ -33,7 +33,6 @@ import com.google.gerrit.server.index.IndexExecutor;
|
|||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -64,7 +63,7 @@ public class AllGroupsIndexer extends SiteIndexer<AccountGroup.UUID, InternalGro
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SiteIndexer.Result indexAll(GroupIndex index) {
|
public SiteIndexer.Result indexAll(GroupIndex index) {
|
||||||
ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
|
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
|
||||||
progress.start(2);
|
progress.start(2);
|
||||||
Stopwatch sw = Stopwatch.createStarted();
|
Stopwatch sw = Stopwatch.createStarted();
|
||||||
List<AccountGroup.UUID> uuids;
|
List<AccountGroup.UUID> uuids;
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
package com.google.gerrit.httpd.raw;
|
package com.google.gerrit.httpd.raw;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.template.soy.data.SoyMapData;
|
import com.google.template.soy.data.SoyMapData;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@@ -30,7 +31,7 @@ public class IndexServletTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String getIndexSource() {
|
String getIndexSource() {
|
||||||
return new String(indexSource);
|
return new String(indexSource, UTF_8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@ import com.google.common.collect.ListMultimap;
|
|||||||
import com.google.common.net.HttpHeaders;
|
import com.google.common.net.HttpHeaders;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -106,7 +107,7 @@ public class FakeHttpServletResponse implements HttpServletResponse {
|
|||||||
public synchronized PrintWriter getWriter() {
|
public synchronized PrintWriter getWriter() {
|
||||||
checkState(outputStream == null, "getOutputStream() already called");
|
checkState(outputStream == null, "getOutputStream() already called");
|
||||||
if (writer == null) {
|
if (writer == null) {
|
||||||
writer = new PrintWriter(actualBody);
|
writer = new PrintWriter(new OutputStreamWriter(actualBody, UTF_8));
|
||||||
}
|
}
|
||||||
return writer;
|
return writer;
|
||||||
}
|
}
|
||||||
|
@@ -68,7 +68,7 @@ java_package_configuration(
|
|||||||
"-Xep:CannotMockFinalClass:WARN",
|
"-Xep:CannotMockFinalClass:WARN",
|
||||||
"-Xep:ClassCanBeStatic:WARN",
|
"-Xep:ClassCanBeStatic:WARN",
|
||||||
"-Xep:ClassNewInstance:WARN",
|
"-Xep:ClassNewInstance:WARN",
|
||||||
"-Xep:DefaultCharset:WARN",
|
"-Xep:DefaultCharset:ERROR",
|
||||||
"-Xep:DoubleCheckedLocking:WARN",
|
"-Xep:DoubleCheckedLocking:WARN",
|
||||||
"-Xep:ElementsCountedInLoop:WARN",
|
"-Xep:ElementsCountedInLoop:WARN",
|
||||||
"-Xep:EqualsHashCode:WARN",
|
"-Xep:EqualsHashCode:WARN",
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
load("//tools/bzl:genrule2.bzl", "genrule2")
|
load("//tools/bzl:genrule2.bzl", "genrule2")
|
||||||
load("//tools/bzl:java.bzl", "java_library2")
|
load("//tools/bzl:java.bzl", "java_library2")
|
||||||
|
|
||||||
jar_filetype = FileType([".jar"])
|
jar_filetype = [".jar"]
|
||||||
|
|
||||||
BROWSERS = [
|
BROWSERS = [
|
||||||
"chrome",
|
"chrome",
|
||||||
@@ -225,7 +225,7 @@ gwt_binary = rule(
|
|||||||
default = Label("@bazel_tools//tools/zip:zipper"),
|
default = Label("@bazel_tools//tools/zip:zipper"),
|
||||||
cfg = "host",
|
cfg = "host",
|
||||||
executable = True,
|
executable = True,
|
||||||
single_file = True,
|
allow_single_file = True,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
outputs = {
|
outputs = {
|
||||||
|
@@ -426,7 +426,7 @@ _bundle_rule = rule(
|
|||||||
|
|
||||||
def bundle_assets(*args, **kwargs):
|
def bundle_assets(*args, **kwargs):
|
||||||
"""Combine html, js, css files and optionally split into js and html bundles."""
|
"""Combine html, js, css files and optionally split into js and html bundles."""
|
||||||
_bundle_rule(*args, pkg = PACKAGE_NAME, **kwargs)
|
_bundle_rule(*args, pkg = native.package_name(), **kwargs)
|
||||||
|
|
||||||
def polygerrit_plugin(name, app, srcs = [], assets = None, **kwargs):
|
def polygerrit_plugin(name, app, srcs = [], assets = None, **kwargs):
|
||||||
"""Bundles plugin dependencies for deployment.
|
"""Bundles plugin dependencies for deployment.
|
||||||
@@ -447,7 +447,7 @@ def polygerrit_plugin(name, app, srcs = [], assets = None, **kwargs):
|
|||||||
name = name + "_combined",
|
name = name + "_combined",
|
||||||
app = app,
|
app = app,
|
||||||
srcs = srcs if app in srcs else srcs + [app],
|
srcs = srcs if app in srcs else srcs + [app],
|
||||||
pkg = PACKAGE_NAME,
|
pkg = native.package_name(),
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ for xml in args.xmls:
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
handled_rules.append(rule_name)
|
handled_rules.append(rule_name)
|
||||||
for c in child.getchildren():
|
for c in list(child):
|
||||||
if c.tag != "rule-input":
|
if c.tag != "rule-input":
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@@ -39,7 +39,7 @@ def license_test(name, target):
|
|||||||
if target[0] not in ":/":
|
if target[0] not in ":/":
|
||||||
target = ":" + target
|
target = ":" + target
|
||||||
if target[0] != "/":
|
if target[0] != "/":
|
||||||
target = "//" + PACKAGE_NAME + target
|
target = "//" + native.package_name() + target
|
||||||
|
|
||||||
forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE"
|
forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE"
|
||||||
native.genquery(
|
native.genquery(
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
# War packaging.
|
# War packaging.
|
||||||
|
|
||||||
jar_filetype = FileType([".jar"])
|
jar_filetype = [".jar"]
|
||||||
|
|
||||||
LIBS = [
|
LIBS = [
|
||||||
"//java/com/google/gerrit/common:version",
|
"//java/com/google/gerrit/common:version",
|
||||||
|
Reference in New Issue
Block a user