apache / apache/maven-ear-plugin
Getter with side-effect mutation in AbstractEarModule.getBundleDir() and getLibDir()
- Dominant language
- Java
- Stars
- 14
- Forks
- 29
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 6
Description
## Description
In `AbstractEarModule.java:240-251`, the getters `getBundleDir()` and `getLibDir()` silently mutate instance state:
```java
public String getBundleDir() {
bundleDir = cleanArchivePath(bundleDir); // modifies field
return bundleDir;
}
public String getLibDir() {
libDirectory = cleanArchivePath(libDirectory);
return libDirectory;
}
```
Getters modifying instance fields is surprising and makes debugging harder. While `cleanArchivePath` is idempotent, the side-effect could cause subtle bugs if a subclass overrides `getBundleDir()` while the parent field gets modified elsewhere.
## Expected behavior
Use a local variable instead of assigning to the field:
```java
public String getBundleDir() {
return cleanArchivePath(bundleDir);
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in AbstractEarModule.java:240-251 and inspect getBundleDir() and getLibDir(), along with cleanArchivePath(). Done means both getters return the cleaned field value without assigning back to instance state; check the existing project tests afterward for regressions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 86/100