From 673d4d38603801857833dd0bdc6b12e25fff6e29 Mon Sep 17 00:00:00 2001 From: Googler Date: Tue, 26 Dec 2023 15:22:33 -0800 Subject: [PATCH] Convert `toString()` to `getMessage()` for `InvalidGlobPatternException` Also changes `PackageFactoryTest#testBadCharacterInGlob(.)` expected error message to reflect the new behavior. PiperOrigin-RevId: 593865516 Change-Id: Ie99ff88aea6528fb3adc3670af1602ea9a3d6ce4 --- .../build/lib/skyframe/InvalidGlobPatternException.java | 4 ++-- .../devtools/build/lib/packages/PackageFactoryTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/InvalidGlobPatternException.java b/src/main/java/com/google/devtools/build/lib/skyframe/InvalidGlobPatternException.java index 852c2fbb3abc8b..9a3eedaf0995d0 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/InvalidGlobPatternException.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/InvalidGlobPatternException.java @@ -26,7 +26,7 @@ public final class InvalidGlobPatternException extends Exception { } @Override - public String toString() { - return String.format("invalid glob pattern '%s': %s", pattern, getMessage()); + public String getMessage() { + return String.format("invalid glob pattern '%s': %s", pattern, super.getMessage()); } } diff --git a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java index 044b13f49859f2..5fedc206c8649b 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/PackageFactoryTest.java @@ -727,7 +727,7 @@ public void testGlobWithSubdirMatchAndExclusion() throws Exception { @Test public void testBadCharacterInGlob() throws Exception { reporter.removeHandler(failFastHandler); - assertGlobFails("glob(['?'])", "Error in glob: wildcard ? forbidden"); + assertGlobFails("glob(['?'])", "Error in glob: invalid glob pattern '?': wildcard ? forbidden"); } @Test