Copilot commented on code in PR #1789:
URL: https://github.com/apache/commons-lang/pull/1789#discussion_r3996375462


##########
src/main/java/org/apache/commons/lang3/reflect/TypeUtils.java:
##########
@@ -1605,6 +1613,8 @@ public static boolean typesSatisfyVariables(final 
Map<TypeVariable<?>, Type> typ
         return true;
     }
 
+    private static final ThreadLocal<Set<TypeVariable<?>>> VISITING = 
ThreadLocal.withInitial(HashSet::new);

Review Comment:
   This guard only tracks `TypeVariable` nodes, so it does not prevent cycles 
through other `Type` implementations. For example, `WildcardTypeBuilder` 
accepts and retains a caller-supplied bounds array; that array can be updated 
after `build()` so the wildcard is its own upper bound, and `toString()` then 
recurses through `wildcardTypeToString`/`AMP_JOINER` without entering this 
guard and still throws `StackOverflowError`. If the formatter is intended to 
handle arbitrary cyclic type graphs, the recursion guard needs to cover all 
supported `Type` nodes (with identity-based tracking), or the scope of the 
guard should be narrowed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to