From 67e172e39b66cc78219113c323b33cbd3b98aac4 Mon Sep 17 00:00:00 2001 From: emcmanus Date: Thu, 4 Apr 2019 07:48:29 -0700 Subject: [PATCH] Output the full exception trace if ServiceLoader fails when looking for AutoValue extensions. See https://github.com/google/auto/issues/718. RELNOTES=More detailed exception information if AutoValue extensions cannot be loaded. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=241929228 --- .../com/google/auto/value/processor/AutoValueProcessor.java | 3 ++- .../java/com/google/auto/value/processor/ExtensionTest.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java b/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java index 2ef9dabc0d..a96bd99f69 100644 --- a/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java +++ b/value/src/main/java/com/google/auto/value/processor/AutoValueProcessor.java @@ -26,6 +26,7 @@ import com.google.auto.value.extension.AutoValueExtension; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Strings; +import com.google.common.base.Throwables; import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableListMultimap; @@ -118,7 +119,7 @@ public synchronized void init(ProcessingEnvironment processingEnv) { if (t instanceof ServiceConfigurationError) { warning.append(" This may be due to a corrupt jar file in the compiler's classpath."); } - warning.append(" Exception: ").append(t); + warning.append("\n").append(Throwables.getStackTraceAsString(t)); errorReporter().reportWarning(warning.toString(), null); extensions = ImmutableList.of(); } diff --git a/value/src/test/java/com/google/auto/value/processor/ExtensionTest.java b/value/src/test/java/com/google/auto/value/processor/ExtensionTest.java index 97f065a658..313fb29ea4 100644 --- a/value/src/test/java/com/google/auto/value/processor/ExtensionTest.java +++ b/value/src/test/java/com/google/auto/value/processor/ExtensionTest.java @@ -616,7 +616,7 @@ private void doTestBadJarDoesntBlowUp(File badJar) throws IOException { .processedWith(new AutoValueProcessor(badJarLoader)) .compilesWithoutError(); success.withWarningContaining( - "This may be due to a corrupt jar file in the compiler's classpath. Exception: " + "This may be due to a corrupt jar file in the compiler's classpath.\n " + ServiceConfigurationError.class.getName()); success .and()