From 9b5fcc6b5557ce173a9cbf845bc93d27fdd4e115 Mon Sep 17 00:00:00 2001 From: Ben Lee Date: Mon, 25 Oct 2021 13:33:36 -0700 Subject: [PATCH] Avoid leaking ResourceShrinkerAction args between requests Keeping the `ResourceShrinkerAction` options in a static field allows these options to leak between requests in a multiplex world. Closes #14145. PiperOrigin-RevId: 405479295 --- .../devtools/build/android/ResourceShrinkerAction.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java index e4e72fcfb6d3e2..bdd33f78a59e42 100644 --- a/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java +++ b/src/tools/android/java/com/google/devtools/build/android/ResourceShrinkerAction.java @@ -218,9 +218,6 @@ public static final class Options extends OptionsBase { public VariantType packageType; } - private static AaptConfigOptions aaptConfigOptions; - private static Options options; - private static String getManifestPackage(Path manifest) throws SAXException, IOException, StreamException, ParserConfigurationException { ManifestData manifestData = AndroidManifestParser.parse(Files.newInputStream(manifest)); @@ -246,8 +243,8 @@ public static void main(String[] args) throws Exception { .argsPreProcessor(new ShellQuotedParamsFilePreProcessor(FileSystems.getDefault())) .build(); optionsParser.parseAndExitUponError(args); - aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class); - options = optionsParser.getOptions(Options.class); + AaptConfigOptions aaptConfigOptions = optionsParser.getOptions(AaptConfigOptions.class); + Options options = optionsParser.getOptions(Options.class); AndroidResourceProcessor resourceProcessor = new AndroidResourceProcessor(stdLogger); // Setup temporary working directories.