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:
David Pursehouse 2018-09-13 09:54:35 +09:00
commit 2f6014055d
12 changed files with 25 additions and 17 deletions

View File

@ -15,12 +15,14 @@
package com.google.gerrit.index;
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.flogger.FluentLogger;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.concurrent.ExecutionException;
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 OutputStream progressOut = NullOutputStream.INSTANCE;
protected PrintWriter verboseWriter = new PrintWriter(NullOutputStream.INSTANCE);
protected PrintWriter verboseWriter = newPrintWriter(NullOutputStream.INSTANCE);
public void setTotalWork(int num) {
totalWork = num;
@ -75,7 +77,7 @@ public abstract class SiteIndexer<K, V, I extends Index<K, V>> {
}
public void setVerboseOut(OutputStream out) {
verboseWriter = new PrintWriter(checkNotNull(out));
verboseWriter = newPrintWriter(checkNotNull(out));
}
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());
}
protected PrintWriter newPrintWriter(OutputStream out) {
return new PrintWriter(new OutputStreamWriter(out, UTF_8));
}
private static class ErrorListener implements Runnable {
private final ListenableFuture<?> future;
private final String desc;

View File

@ -16,6 +16,7 @@ package com.google.gerrit.pgm;
import static com.google.common.base.MoreObjects.firstNonNull;
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.toList;
@ -39,6 +40,7 @@ import com.google.gerrit.server.schema.DataSourceType;
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Provider;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
@ -141,7 +143,7 @@ public class MigrateToNoteDb extends SiteProgram {
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);
}
} finally {

View File

@ -30,7 +30,6 @@ import com.google.gerrit.server.index.IndexExecutor;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -60,7 +59,7 @@ public class AllAccountsIndexer extends SiteIndexer<Account.Id, AccountState, Ac
@Override
public SiteIndexer.Result indexAll(AccountIndex index) {
ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
progress.start(2);
Stopwatch sw = Stopwatch.createStarted();
List<Account.Id> ids;

View File

@ -33,7 +33,6 @@ import com.google.gerrit.server.index.IndexExecutor;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -64,7 +63,7 @@ public class AllGroupsIndexer extends SiteIndexer<AccountGroup.UUID, InternalGro
@Override
public SiteIndexer.Result indexAll(GroupIndex index) {
ProgressMonitor progress = new TextProgressMonitor(new PrintWriter(progressOut));
ProgressMonitor progress = new TextProgressMonitor(newPrintWriter(progressOut));
progress.start(2);
Stopwatch sw = Stopwatch.createStarted();
List<AccountGroup.UUID> uuids;

View File

@ -15,6 +15,7 @@
package com.google.gerrit.httpd.raw;
import static com.google.common.truth.Truth.assertThat;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.template.soy.data.SoyMapData;
import java.net.URISyntaxException;
@ -30,7 +31,7 @@ public class IndexServletTest {
}
String getIndexSource() {
return new String(indexSource);
return new String(indexSource, UTF_8);
}
}

View File

@ -25,6 +25,7 @@ import com.google.common.collect.ListMultimap;
import com.google.common.net.HttpHeaders;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.util.Collection;
@ -106,7 +107,7 @@ public class FakeHttpServletResponse implements HttpServletResponse {
public synchronized PrintWriter getWriter() {
checkState(outputStream == null, "getOutputStream() already called");
if (writer == null) {
writer = new PrintWriter(actualBody);
writer = new PrintWriter(new OutputStreamWriter(actualBody, UTF_8));
}
return writer;
}

View File

@ -68,7 +68,7 @@ java_package_configuration(
"-Xep:CannotMockFinalClass:WARN",
"-Xep:ClassCanBeStatic:WARN",
"-Xep:ClassNewInstance:WARN",
"-Xep:DefaultCharset:WARN",
"-Xep:DefaultCharset:ERROR",
"-Xep:DoubleCheckedLocking:WARN",
"-Xep:ElementsCountedInLoop:WARN",
"-Xep:EqualsHashCode:WARN",

View File

@ -15,7 +15,7 @@
load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:java.bzl", "java_library2")
jar_filetype = FileType([".jar"])
jar_filetype = [".jar"]
BROWSERS = [
"chrome",
@ -225,7 +225,7 @@ gwt_binary = rule(
default = Label("@bazel_tools//tools/zip:zipper"),
cfg = "host",
executable = True,
single_file = True,
allow_single_file = True,
),
},
outputs = {

View File

@ -426,7 +426,7 @@ _bundle_rule = rule(
def bundle_assets(*args, **kwargs):
"""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):
"""Bundles plugin dependencies for deployment.
@ -447,7 +447,7 @@ def polygerrit_plugin(name, app, srcs = [], assets = None, **kwargs):
name = name + "_combined",
app = app,
srcs = srcs if app in srcs else srcs + [app],
pkg = PACKAGE_NAME,
pkg = native.package_name(),
**kwargs
)

View File

@ -35,7 +35,7 @@ for xml in args.xmls:
continue
handled_rules.append(rule_name)
for c in child.getchildren():
for c in list(child):
if c.tag != "rule-input":
continue

View File

@ -39,7 +39,7 @@ def license_test(name, target):
if target[0] not in ":/":
target = ":" + target
if target[0] != "/":
target = "//" + PACKAGE_NAME + target
target = "//" + native.package_name() + target
forbidden = "//lib:LICENSE-DO_NOT_DISTRIBUTE"
native.genquery(

View File

@ -14,7 +14,7 @@
# War packaging.
jar_filetype = FileType([".jar"])
jar_filetype = [".jar"]
LIBS = [
"//java/com/google/gerrit/common:version",