Enable error level for the UnescapedEntity bug pattern in ErrorProne
Fix the current issues so that the build continues to work.
Signed-off-by: Edwin Kempin <ekempin@google.com>
Change-Id: I2b6ad7134312b912f399ed665bf03f2a2a5eea84
diff --git a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java
index 738be4d..2dd3f91 100644
--- a/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java
+++ b/java/com/google/gerrit/acceptance/testsuite/project/ProjectOperations.java
@@ -81,11 +81,11 @@
*
* <p>Example:
*
- * <pre>
+ * <pre>{@code
* projectOperations.forInvalidation()
* .addProjectConfigUpdater(cfg -> cfg.setString("invalidSection", null, "foo", "bar"))
* .invalidate();
- * </pre>
+ * }</pre>
*
* <p><strong>Note:</strong> The invalidation will fail with an exception if the project to
* invalidate doesn't exist.
diff --git a/java/com/google/gerrit/extensions/conditions/BooleanCondition.java b/java/com/google/gerrit/extensions/conditions/BooleanCondition.java
index 97543af..9c354fb 100644
--- a/java/com/google/gerrit/extensions/conditions/BooleanCondition.java
+++ b/java/com/google/gerrit/extensions/conditions/BooleanCondition.java
@@ -63,7 +63,9 @@
* Reduce evaluation tree by cutting off branches that evaluate trivially and replacing them with
* a leave note corresponding to the value the branch evaluated to.
*
- * <p><code>
+ * <p>
+ *
+ * <pre>{@code
* Example 1 (T=True, F=False, C=non-trivial check):
* OR
* / \ => T
@@ -76,7 +78,7 @@
* AND
* / \ => F
* T F
- * </code>
+ * }</pre>
*
* <p>There is no guarantee that the resulting tree is minimal. The only guarantee made is that
* branches that evaluate trivially will be cut off and replaced by primitive values.
diff --git a/java/com/google/gerrit/gpg/testing/TestKeys.java b/java/com/google/gerrit/gpg/testing/TestKeys.java
index de66889..0423474 100644
--- a/java/com/google/gerrit/gpg/testing/TestKeys.java
+++ b/java/com/google/gerrit/gpg/testing/TestKeys.java
@@ -436,13 +436,13 @@
/**
* A key with an additional user ID.
*
- * <pre>
+ * <pre>{@code
* pub 2048R/98C51DBF 2015-07-30
* Key fingerprint = 42B3 294D 1924 D7EB AF4A A99F 5024 BB44 98C5 1DBF
* uid foo:myId
* uid Testuser Five <test5@example.com>
* sub 2048R/C781A9E3 2015-07-30
- * </pre>
+ * }</pre>
*/
public static TestKey validKeyWithSecondUserId() {
return new TestKey(
@@ -1033,13 +1033,13 @@
/**
* Master Key without expiration with subkey with expiration.
*
- * <pre>
+ * <pre>{@code
* pub rsa1024 2018-11-17 [C]
* 5734 2C37 982A 843B 19C0 622B 6AAF 2D26 B481 02DB
* uid [ultimate] Testuser 10 <testuser10@example.com>
* sub rsa1024 2018-11-17 [S] [expires: 2065-11-05]
* 0A4A 9660 1B96 2DFC E898 E686 4305 C92E 626E B485
- * </pre>
+ * }</pre>
*/
public static TestKey validKeyWithoutExpirationWithSubkeyWithExpiration() throws Exception {
return new TestKey(
diff --git a/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java b/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java
index b37e489..4032e63 100644
--- a/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java
+++ b/java/com/google/gerrit/server/config/ConfigUpdatedEvent.java
@@ -32,9 +32,9 @@
* <p>1. Help the callers figure out if any action should be taken, depending on which entries are
* updated in gerrit.config.
*
- * <p>2. Provide the callers with a mechanism to accept/reject the entries of interest: @see
- * accept(Set<ConfigKey> entries), @see accept(String section), @see reject(Set<ConfigKey> entries)
- * (+ various overloaded versions of these)
+ * <p>2. Provide the callers with a mechanism to accept/reject the entries of interest: {@link
+ * #accept(Set)}, {@link #accept(String)}, {@link #reject(Set)} (+ various overloaded versions of
+ * these)
*/
public class ConfigUpdatedEvent {
public static final ImmutableMultimap<UpdateResult, ConfigUpdateEntry> NO_UPDATES =
diff --git a/java/com/google/gerrit/server/logging/CallerFinder.java b/java/com/google/gerrit/server/logging/CallerFinder.java
index bd7e608..4cb4b7f 100644
--- a/java/com/google/gerrit/server/logging/CallerFinder.java
+++ b/java/com/google/gerrit/server/logging/CallerFinder.java
@@ -41,7 +41,7 @@
*
* <p>E.g. the stacktrace could look like this:
*
- * <pre>
+ * <pre>{@code
* GroupQueryProcessor(QueryProcessor<T>).query(List<String>, List<Predicate<T>>) line: 216
* GroupQueryProcessor(QueryProcessor<T>).query(List<Predicate<T>>) line: 188
* GroupQueryProcessor(QueryProcessor<T>).query(Predicate<T>) line: 171
@@ -52,7 +52,7 @@
* GroupCacheImpl$ByNameLoader.load(Object) line: 1
* LocalCache$LoadingValueReference<K,V>.loadFuture(K, CacheLoader<? super K,V>) line: 3527
* ...
- * </pre>
+ * }</pre>
*
* <p>The first interesting caller is {@code GroupCacheImpl$ByNameLoader.load(String) line: 166}. To
* find this caller from the stacktrace we could specify {@link
diff --git a/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java b/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java
index 3c4c563..1bba018 100644
--- a/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java
+++ b/java/com/google/gerrit/server/logging/LoggingContextAwareRunnable.java
@@ -28,24 +28,24 @@
*
* <p>Example:
*
- * <pre>
- * try (TraceContext traceContext = TraceContext.newTrace(true, ...)) {
- * executor
- * .submit(new LoggingContextAwareRunnable(
- * () -> {
- * // Tracing is enabled since the runnable is created within the TraceContext.
- * // Tracing is even enabled if the executor runs the runnable only after the
- * // TraceContext was closed.
+ * <pre>{@code
+ * try (TraceContext traceContext = TraceContext.newTrace(true, ...)) {
+ * executor
+ * .submit(new LoggingContextAwareRunnable(
+ * () -> {
+ * // Tracing is enabled since the runnable is created within the TraceContext.
+ * // Tracing is even enabled if the executor runs the runnable only after the
+ * // TraceContext was closed.
*
- * // The tag "foo=bar" is not set, since it was added to the logging context only
- * // after this runnable was created.
+ * // The tag "foo=bar" is not set, since it was added to the logging context only
+ * // after this runnable was created.
*
- * // do stuff
- * }))
- * .get();
- * traceContext.addTag("foo", "bar");
- * }
- * </pre>
+ * // do stuff
+ * }))
+ * .get();
+ * traceContext.addTag("foo", "bar");
+ * }
+ * }</pre>
*
* @see LoggingContextAwareCallable
*/
diff --git a/java/com/google/gerrit/server/plugincontext/PluginContext.java b/java/com/google/gerrit/server/plugincontext/PluginContext.java
index ef2e181..a5fad56 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginContext.java
@@ -54,7 +54,7 @@
* <p>A plugin context can be manually opened by invoking the newTrace methods. This should only be
* needed if an extension throws multiple exceptions that need to be handled:
*
- * <pre>
+ * <pre>{@code
* public interface Foo {
* void doFoo() throws Exception1, Exception2, Exception3;
* }
@@ -66,7 +66,7 @@
* fooExtension.get().doFoo();
* }
* }
- * </pre>
+ * }</pre>
*
* <p>This class hosts static methods with generic functionality to invoke plugin extensions with a
* trace context that are commonly used by {@link PluginItemContext}, {@link PluginSetContext} and
diff --git a/java/com/google/gerrit/server/plugincontext/PluginItemContext.java b/java/com/google/gerrit/server/plugincontext/PluginItemContext.java
index 421b3ad..e88a6fe 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginItemContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginItemContext.java
@@ -40,46 +40,46 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* fooPluginItemContext.run(foo -> foo.doFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* try {
* fooPluginItemContext.run(foo -> foo.doFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result = fooPluginItemContext.call(foo -> foo.getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result;
* try {
* result = fooPluginItemContext.call(foo -> foo.getFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* try (TraceContext traceContext = PluginContext.newTrace(fooDynamicItem.getEntry())) {
* fooDynamicItem.get().doFoo();
* } catch (MyException1 | MyException2 | MyException3 e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*/
public class PluginItemContext<T> {
@Nullable private final DynamicItem<T> dynamicItem;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginMapContext.java b/java/com/google/gerrit/server/plugincontext/PluginMapContext.java
index b02ad27..fb50cd5 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginMapContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginMapContext.java
@@ -33,15 +33,15 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* fooPluginMapContext.runEach(
* extension -> results.put(extension.getExportName(), extension.get().getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* try {
* fooPluginMapContext.runEach(
@@ -50,22 +50,22 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* for (PluginMapEntryContext<Foo> c : fooPluginMapContext) {
* if (c.call(extension -> extension.get().handles(x))) {
* c.run(extension -> results.put(extension.getExportName(), extension.get().getFoo());
* }
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* try {
* for (PluginMapEntryContext<Foo> c : fooPluginMapContext) {
@@ -77,11 +77,11 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicMap) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -89,7 +89,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginMapContext<T> implements Iterable<PluginMapEntryContext<T>> {
private final DynamicMap<T> dynamicMap;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java b/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java
index 68589cf..27181cb 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginMapEntryContext.java
@@ -35,15 +35,15 @@
*
* <p>The call* methods execute the extension and deliver a result back to the caller.
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* fooPluginMapEntryContext.run(
* extension -> results.put(extension.getExportName(), extension.get().getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* Map<String, Object> results = new HashMap<>();
* try {
* fooPluginMapEntryContext.run(
@@ -52,28 +52,28 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result = fooPluginMapEntryContext.call(extension -> extension.get().getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result;
* try {
* result = fooPluginMapEntryContext.call(extension -> extension.get().getFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicMap) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -81,7 +81,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginMapEntryContext<T> {
private final Extension<T> extension;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginSetContext.java b/java/com/google/gerrit/server/plugincontext/PluginSetContext.java
index b64cfeb..43c9552 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginSetContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginSetContext.java
@@ -34,33 +34,33 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* fooPluginSetContext.runEach(foo -> foo.doFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* try {
* fooPluginSetContext.runEach(foo -> foo.doFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* for (PluginSetEntryContext<Foo> c : fooPluginSetContext) {
* if (c.call(foo -> foo.handles(x))) {
* c.run(foo -> foo.doFoo());
* }
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* try {
* for (PluginSetEntryContext<Foo> c : fooPluginSetContext) {
* if (c.call(foo -> foo.handles(x), MyException.class)) {
@@ -70,11 +70,11 @@
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicSet.entries()) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -82,7 +82,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginSetContext<T> implements Iterable<PluginSetEntryContext<T>> {
private final DynamicSet<T> dynamicSet;
diff --git a/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java b/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java
index 2268c07..be97b52 100644
--- a/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java
+++ b/java/com/google/gerrit/server/plugincontext/PluginSetEntryContext.java
@@ -37,40 +37,40 @@
*
* <p>Example if all exceptions should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* fooPluginSetEntryContext.run(foo -> foo.doFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if all exceptions, but one, should be caught and logged:
*
- * <pre>
+ * <pre>{@code
* try {
* fooPluginSetEntryContext.run(foo -> foo.doFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if return values should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result = fooPluginSetEntryContext.call(foo -> foo.getFoo());
- * </pre>
+ * }</pre>
*
* <p>Example if return values and a single exception should be handled:
*
- * <pre>
+ * <pre>{@code
* Object result;
* try {
* result = fooPluginSetEntryContext.call(foo -> foo.getFoo(), MyException.class);
* } catch (MyException e) {
* // handle the exception
* }
- * </pre>
+ * }</pre>
*
* <p>Example if several exceptions should be handled:
*
- * <pre>
+ * <pre>{@code
* for (Extension<Foo> fooExtension : fooDynamicSet.entries()) {
* try (TraceContext traceContext = PluginContext.newTrace(fooExtension)) {
* fooExtension.get().doFoo();
@@ -78,7 +78,7 @@
* // handle the exception
* }
* }
- * </pre>
+ * }</pre>
*/
public class PluginSetEntryContext<T> {
private final Extension<T> extension;
diff --git a/java/com/google/gerrit/testing/GerritJUnit.java b/java/com/google/gerrit/testing/GerritJUnit.java
index 0771c39..e80afa9 100644
--- a/java/com/google/gerrit/testing/GerritJUnit.java
+++ b/java/com/google/gerrit/testing/GerritJUnit.java
@@ -26,11 +26,11 @@
* <p>This construction is recommended by the Truth team for use in conjunction with asserting
* over a {@code ThrowableSubject} on the return type:
*
- * <pre>
- * MyException e = assertThrows(MyException.class, () -> doSomething(foo));
- * assertThat(e).isInstanceOf(MySubException.class);
- * assertThat(e).hasMessageThat().contains("sub-exception occurred");
- * </pre>
+ * <pre>{@code
+ * MyException e = assertThrows(MyException.class, () -> doSomething(foo));
+ * assertThat(e).isInstanceOf(MySubException.class);
+ * assertThat(e).hasMessageThat().contains("sub-exception occurred");
+ * }</pre>
*
* @param throwableClass expected exception type.
* @param runnable runnable containing arbitrary code.
diff --git a/tools/BUILD b/tools/BUILD
index 0753f4e..1bace53 100644
--- a/tools/BUILD
+++ b/tools/BUILD
@@ -431,7 +431,7 @@
"-Xep:TypeParameterUnusedInFormals:ERROR",
"-Xep:URLEqualsHashCode:ERROR",
# "-Xep:UndefinedEquals:WARN",
- # "-Xep:UnescapedEntity:WARN",
+ "-Xep:UnescapedEntity:ERROR",
"-Xep:UnnecessaryAssignment:ERROR",
"-Xep:UnnecessaryCheckNotNull:ERROR",
# "-Xep:UnnecessaryLambda:WARN",