apache / apache/maven-dependency-tree

DependencyCollectorRequest.getConfigProperties() exposes the mutable backing map

Open Beginner friendly
#140 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
27
Forks
31
Avg merge
5h 53m
Merged PRs (30d)
1

Description

## Summary
`DependencyCollectorRequest.getConfigProperties()` returns the internal backing `Map` directly, so callers can mutate the request after construction without going through `addConfigProperty(...)`/`removeConfigProperty(...)`. If the map is later shared or reused, this breaks the encapsulation those helpers exist to provide.

## Affected code
`src/main/java/org/apache/maven/shared/dependency/graph/collector/DependencyCollectorRequest.java:130-132`

## Impact
- External mutation bypasses the add/remove API (and any future validation/normalization added there).
- A caller holding the returned map while the request is used concurrently can observe inconsistent configuration.

## Suggested fix
Return an unmodifiable copy/view from `getConfigProperties()` (e.g. `Collections.unmodifiableMap(new HashMap<>(configProperties))`) or a shallow copy, and add a test asserting the returned map cannot modify the request.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in src/main/java/org/apache/maven/shared/dependency/graph/collector/DependencyCollectorRequest.java at lines 130-132 and inspect the existing addConfigProperty(...) and removeConfigProperty(...) behavior. Add a focused test showing that the map returned by getConfigProperties() cannot mutate the request, then run the relevant Maven tests to confirm the helper methods still work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
85/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.