Commit 243d0719 authored by Sam Maier's avatar Sam Maier Committed by Chromium LUCI CQ

Errorprone: enabling ModifyCollectionInEnhancedForLoop check

This also requires us to fix the one failing location.

Bug: 1029038
Change-Id: I85591b3c0d435d5ef9e725a8d27167aa266af3a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2593837Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarAndrew Grieve <agrieve@chromium.org>
Commit-Queue: Richard Coles <torne@chromium.org>
Auto-Submit: Sam Maier <smaier@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837630}
parent 6f7ad7b3
...@@ -14,6 +14,7 @@ import java.io.File; ...@@ -14,6 +14,7 @@ import java.io.File;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Map; import java.util.Map;
/** /**
...@@ -56,14 +57,16 @@ public class SplitApkWorkaround { ...@@ -56,14 +57,16 @@ public class SplitApkWorkaround {
// Synchronize on the map while trying to update it, as the framework does. // Synchronize on the map while trying to update it, as the framework does.
synchronized (loaders) { synchronized (loaders) {
for (Map.Entry<String, ClassLoader> entry : loaders.entrySet()) { // Copy of loaders keys, since we plan to modify loaders while iterating.
ArrayList<String> keys = new ArrayList(loaders.keySet());
for (String cacheKey : keys) {
try { try {
if (!(entry.getValue() instanceof BaseDexClassLoader)) { ClassLoader value = loaders.get(cacheKey);
if (!(value instanceof BaseDexClassLoader)) {
// If it's some other type it can't be the right one. // If it's some other type it can't be the right one.
continue; continue;
} }
String cacheKey = entry.getKey(); BaseDexClassLoader cl = (BaseDexClassLoader) value;
BaseDexClassLoader cl = (BaseDexClassLoader) entry.getValue();
// Get the list of files that this classloader uses as its classpath. // Get the list of files that this classloader uses as its classpath.
Object pathList = pathListField.get(cl); Object pathList = pathListField.get(cl);
......
...@@ -33,7 +33,6 @@ _JAVAC_EXTRACTOR = os.path.join(build_utils.DIR_SOURCE_ROOT, 'third_party', ...@@ -33,7 +33,6 @@ _JAVAC_EXTRACTOR = os.path.join(build_utils.DIR_SOURCE_ROOT, 'third_party',
ERRORPRONE_WARNINGS_TO_DISABLE = [ ERRORPRONE_WARNINGS_TO_DISABLE = [
# These should really be turned on. # These should really be turned on.
'CollectionUndefinedEquality', 'CollectionUndefinedEquality',
'ModifyCollectionInEnhancedForLoop',
# The following are super useful, but existing issues need to be fixed first # The following are super useful, but existing issues need to be fixed first
# before they can start failing the build on new errors. # before they can start failing the build on new errors.
'InvalidParam', 'InvalidParam',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment