Fix minor code issues flagged by error prone

The review of this PR hightlighted a few points about following the advice of the linter
- any advice about changing default character encoding to an explicit one is incorrect for Bazel
- we should generally not expand the potential text of an exception to include more data. That may adversely increase the amount of logging output.

In general, the only linter suggestion which should be followed without careful inspection are those that can not possibly modify behavior.

Closes #11542.

Change-Id: I0162f5e6c13a52af1a6d5bcb06d826371b6ebcc7
PiperOrigin-RevId: 320237874
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
index aee05d6..fca3374 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/RuleContext.java
@@ -483,8 +483,11 @@
   }
 
   @Nullable
-  protected <T extends Fragment> T getFragment(Class<T> fragment, String name,
-      String additionalErrorMessage, ConfigurationTransition transition) {
+  <T extends Fragment> T getFragment(
+      Class<T> fragment,
+      String name,
+      String additionalErrorMessage,
+      ConfigurationTransition transition) {
     // TODO(bazel-team): The fragments can also be accessed directly through BuildConfiguration.
     // Can we lock that down somehow?
     Preconditions.checkArgument(isLegalFragment(fragment, transition),
@@ -708,6 +711,7 @@
    * configuration. The choice of which tree to use is based on the rule with which this target
    * (which must be an OutputFile or a Rule) is associated.
    */
+  @Override
   public ArtifactRoot getBinOrGenfilesDirectory() {
     return rule.hasBinaryOutput()
         ? getConfiguration().getBinDirectory(rule.getRepository())
@@ -1508,12 +1512,12 @@
   }
 
   /**
-   * Returns a path fragment qualified by the rule name and unique fragment to
-   * disambiguate artifacts produced from the source file appearing in
-   * multiple rules.
+   * Returns a path fragment qualified by the rule name and unique fragment to disambiguate
+   * artifacts produced from the source file appearing in multiple rules.
    *
    * <p>For example "pkg/dir/name" -> "pkg/&lt;fragment>/rule/dir/name.
    */
+  @Override
   public final PathFragment getUniqueDirectory(PathFragment fragment) {
     return AnalysisUtils.getUniqueDirectory(getLabel(), fragment);
   }