elharo opened a new issue, #139: URL: https://github.com/apache/maven-dependency-tree/issues/139
## Summary `SerializingDependencyNodeVisitor` keeps traversal state in instance fields (`depth`), mutated in `visit(...)`/`endVisit(...)` and read in `getTree(...)`. This makes the visitor neither thread-safe nor safely reentrant: - Two threads sharing one visitor instance interleave and corrupt the indentation output. - The same visitor reused for two separate graphs carries stale `depth` between runs. ## Affected code `src/main/java/org/apache/maven/shared/dependency/graph/traversal/SerializingDependencyNodeVisitor.java` - `depth` field: line 53 - mutated in `visit(...)`: lines 113-118 and `endVisit(...)`: lines 132-133 - read in `getTree(...)`: lines 89-96 ## Impact `SerializingDependencyNodeVisitor` is the type exposed by `DefaultDependencyNode.getTree(...)`; any caller that reuses or shares the visitor across nodes/threads gets garbled or incorrect output. ## Suggested fix Make the depth state local to each traversal (e.g. pass a per-run state object through the visitor, or document that each traversal must use a fresh instance), and add a test showing reuse produces correct output. -- 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]
