Merge branch 'stable-2.14' into stable-2.15

* stable-2.14:
  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: I09e48fb82a8d5dbec8712932eba463902d339980
This commit is contained in:
David Pursehouse 2018-09-12 14:17:28 +09:00
commit 19e4c40b53
9 changed files with 18 additions and 13 deletions

View File

@ -15,11 +15,13 @@
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.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;
@ -65,7 +67,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;
@ -76,7 +78,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);
@ -87,6 +89,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

@ -29,7 +29,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.concurrent.ExecutionException;
@ -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

@ -32,7 +32,6 @@ import com.google.gwtorm.server.OrmException;
import com.google.gwtorm.server.SchemaFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
@ -67,7 +66,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

@ -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

@ -17,7 +17,7 @@
load("//tools/bzl:genrule2.bzl", "genrule2")
load("//tools/bzl:java.bzl", "java_library2")
jar_filetype = FileType([".jar"])
jar_filetype = [".jar"]
BROWSERS = [
"chrome",
@ -224,7 +224,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

@ -415,4 +415,4 @@ _vulcanize_rule = rule(
def vulcanize(*args, **kwargs):
"""Vulcanize runs vulcanize and crisper on a set of sources."""
_vulcanize_rule(*args, pkg = PACKAGE_NAME, **kwargs)
_vulcanize_rule(*args, pkg = native.package_name(), **kwargs)

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 = [
"//gerrit-war:init",