Github user jwagenleitner commented on a diff in the pull request:
https://github.com/apache/groovy/pull/489#discussion_r99482851
--- Diff: src/main/org/codehaus/groovy/reflection/ClassInfo.java ---
@@ -186,30 +185,20 @@ public void setStrongMetaClass(MetaClass answer) {
MetaClass strongRef = strongMetaClass;
if (strongRef instanceof ExpandoMetaClass) {
- ((ExpandoMetaClass)strongRef).inRegistry = false;
- synchronized(modifiedExpandos){
- for (Iterator<ClassInfo> it = modifiedExpandos.iterator();
it.hasNext(); ) {
- ClassInfo info = it.next();
- if(info == this){
- it.remove();
- }
+ ((ExpandoMetaClass)strongRef).inRegistry = false;
+ for (Iterator<ClassInfo> itr = modifiedExpandos.iterator();
itr.hasNext(); ) {
+ ClassInfo info = itr.next();
+ if(info == this) {
+ itr.remove();
+ }
}
- }
}
strongMetaClass = answer;
if (answer instanceof ExpandoMetaClass) {
- ((ExpandoMetaClass)answer).inRegistry = true;
- synchronized(modifiedExpandos){
- for (Iterator<ClassInfo> it = modifiedExpandos.iterator();
it.hasNext(); ) {
- ClassInfo info = it.next();
- if(info == this){
- it.remove();
- }
- }
- modifiedExpandos.add(this);
- }
--- End diff --
Removed because it appeared to be a duplicate of the logic above. Only if
the previous previous `strongMetaClass` value was an expando would it have been
added to the map, so the iteration/removal above should have taken care to
remove this `ClassInfo` from the `modifiedExpandos` and there's no reason to
iterate again.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---