Merge branch 'stable-2.16' into stable-3.0

* stable-2.16:
  Make toString(), hashCode(), equals() and friends final in AutoValue classes
  Schema_169: Increase log severity level
  Schema_146: Fix FutureReturnValueIgnored warning flagged by error prone
  Fix various usages of the Flogger API
  Schema_169: Fix usage of Flogger to log exception stack trace
  Keep alive database connection to prevent exceeding wait timeout

Change-Id: Ic8885a66acb123b52a30a74a63a2b2e5411dd453
This commit is contained in:
David Pursehouse
2020-04-27 14:27:27 +09:00
13 changed files with 19 additions and 17 deletions

View File

@@ -284,7 +284,7 @@ class OpenIdServiceImpl {
// right now. Instead of blocking all of them log the error and // right now. Instead of blocking all of them log the error and
// let the authentication complete anyway. // let the authentication complete anyway.
// //
logger.atSevere().log("Invalid PAPE response %s: %s", openidIdentifier, err); logger.atSevere().withCause(err).log("Invalid PAPE response from %s", openidIdentifier);
unsupported = true; unsupported = true;
ext = null; ext = null;
} }

View File

@@ -105,7 +105,7 @@ public class StarredChangesUtil {
public abstract String label(); public abstract String label();
@Override @Override
public String toString() { public final String toString() {
return accountId() + SEPARATOR + label(); return accountId() + SEPARATOR + label();
} }
} }

View File

@@ -263,7 +263,7 @@ public class ProjectWatches {
public abstract ImmutableSet<NotifyType> notifyTypes(); public abstract ImmutableSet<NotifyType> notifyTypes();
@Override @Override
public String toString() { public final String toString() {
List<NotifyType> notifyTypes = new ArrayList<>(notifyTypes()); List<NotifyType> notifyTypes = new ArrayList<>(notifyTypes());
StringBuilder notifyValue = new StringBuilder(); StringBuilder notifyValue = new StringBuilder();
notifyValue.append(firstNonNull(filter(), FILTER_ALL)).append(" ["); notifyValue.append(firstNonNull(filter(), FILTER_ALL)).append(" [");

View File

@@ -196,7 +196,7 @@ public abstract class ExternalId implements Serializable {
} }
@Override @Override
public String toString() { public final String toString() {
return get(); return get();
} }
@@ -445,7 +445,7 @@ public abstract class ExternalId implements Serializable {
* that was loaded from Git can be equal with an external ID that was created from code. * that was loaded from Git can be equal with an external ID that was created from code.
*/ */
@Override @Override
public boolean equals(Object obj) { public final boolean equals(Object obj) {
if (!(obj instanceof ExternalId)) { if (!(obj instanceof ExternalId)) {
return false; return false;
} }
@@ -457,7 +457,7 @@ public abstract class ExternalId implements Serializable {
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return Objects.hash(key(), accountId(), email(), password()); return Objects.hash(key(), accountId(), email(), password());
} }
@@ -475,7 +475,7 @@ public abstract class ExternalId implements Serializable {
* </pre> * </pre>
*/ */
@Override @Override
public String toString() { public final String toString() {
Config c = new Config(); Config c = new Config();
writeToConfig(c); writeToConfig(c);
return c.toText(); return c.toText();

View File

@@ -65,7 +65,7 @@ public abstract class ChangeTriplet {
public abstract Change.Key id(); public abstract Change.Key id();
@Override @Override
public String toString() { public final String toString() {
return format(branch(), id()); return format(branch(), id());
} }
} }

View File

@@ -34,7 +34,7 @@ public abstract class ConfigKey {
} }
@Override @Override
public String toString() { public final String toString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(section()).append("."); sb.append(section()).append(".");
if (subsection() != null) { if (subsection() != null) {

View File

@@ -230,7 +230,8 @@ public class PluginConfigFactory implements ReloadPluginListener {
cfg.load(); cfg.load();
} catch (ConfigInvalidException e) { } catch (ConfigInvalidException e) {
// This is an error in user input, don't spam logs with a stack trace. // This is an error in user input, don't spam logs with a stack trace.
logger.atWarning().log("Failed to load %s: %s", pluginConfigFile.toAbsolutePath(), e); logger.atWarning().log(
"Failed to load %s: %s", pluginConfigFile.toAbsolutePath(), e.getMessage());
} catch (IOException e) { } catch (IOException e) {
logger.atWarning().withCause(e).log("Failed to load %s", pluginConfigFile.toAbsolutePath()); logger.atWarning().withCause(e).log("Failed to load %s", pluginConfigFile.toAbsolutePath());
} }

View File

@@ -194,7 +194,7 @@ public abstract class ScheduleConfig {
} }
@Override @Override
public String toString() { public final String toString() {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(formatValue(keyInterval())); b.append(formatValue(keyInterval()));
b.append(", "); b.append(", ");

View File

@@ -157,11 +157,11 @@ public class Text extends RawText {
return Charset.forName(encoding); return Charset.forName(encoding);
} catch (IllegalCharsetNameException err) { } catch (IllegalCharsetNameException err) {
logger.atSevere().log("Invalid detected charset name '%s': %s", encoding, err); logger.atSevere().log("Invalid detected charset name '%s': %s", encoding, err.getMessage());
return ISO_8859_1; return ISO_8859_1;
} catch (UnsupportedCharsetException err) { } catch (UnsupportedCharsetException err) {
logger.atSevere().log("Detected charset '%s' not supported: %s", encoding, err); logger.atSevere().log("Detected charset '%s' not supported: %s", encoding, err.getMessage());
return ISO_8859_1; return ISO_8859_1;
} }
} }

View File

@@ -141,7 +141,7 @@ public class SectionSortCache {
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return cachedHashCode(); return cachedHashCode();
} }
} }

View File

@@ -260,12 +260,12 @@ class RelatedChangesSorter {
} }
@Override @Override
public int hashCode() { public final int hashCode() {
return Objects.hash(patchSet().getId(), commit()); return Objects.hash(patchSet().getId(), commit());
} }
@Override @Override
public boolean equals(Object obj) { public final boolean equals(Object obj) {
if (!(obj instanceof PatchSetData)) { if (!(obj instanceof PatchSetData)) {
return false; return false;
} }

View File

@@ -85,7 +85,7 @@ public abstract class LabelVote {
} }
@Override @Override
public String toString() { public final String toString() {
return format(); return format();
} }
} }

View File

@@ -26,6 +26,7 @@ java_package_configuration(
javacopts = [ javacopts = [
"-XepDisableWarningsInGeneratedCode", "-XepDisableWarningsInGeneratedCode",
"-Xep:AmbiguousMethodReference:WARN", "-Xep:AmbiguousMethodReference:WARN",
"-Xep:AutoValueFinalMethods:ERROR",
"-Xep:BadAnnotationImplementation:WARN", "-Xep:BadAnnotationImplementation:WARN",
"-Xep:BadComparable:WARN", "-Xep:BadComparable:WARN",
"-Xep:BoxedPrimitiveConstructor:ERROR", "-Xep:BoxedPrimitiveConstructor:ERROR",