mgalbis commented on code in PR #645:
URL:
https://github.com/apache/commons-configuration/pull/645#discussion_r3583173054
##########
src/main/java/org/apache/commons/configuration2/convert/AbstractListDelimiterHandler.java:
##########
@@ -42,24 +43,23 @@ public abstract class AbstractListDelimiterHandler
implements ListDelimiterHandl
static Collection<?> flatten(final ListDelimiterHandler handler, final
Object value, final int limit, final Set<Object> dejaVu) {
if (value instanceof String) {
return handler.split((String) value, true);
+ } else if (!isRecursiveContainer(value)) {
+ return value != null ? Collections.singletonList(value) :
Collections.emptyList();
}
dejaVu.add(value);
final Collection<Object> result = new LinkedList<>();
- if (value instanceof Path) {
- // Don't handle as an Iterable.
- result.add(value);
- } else if (value instanceof Iterable) {
- flattenIterator(handler, result, ((Iterable<?>) value).iterator(),
limit, dejaVu);
- } else if (value instanceof Iterator) {
- flattenIterator(handler, result, (Iterator<?>) value, limit,
dejaVu);
- } else if (value != null) {
- if (value.getClass().isArray()) {
+ try {
+ if (value instanceof Iterable) {
+ flattenIterator(handler, result, ((Iterable<?>)
value).iterator(), limit, dejaVu);
Review Comment:
Fixed by centralizing the recursion-path check in flatten() and reusing the
same dejaVu set when processing array elements. I also added coverage for array
cycles.
--
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]