apache / apache/maven-shared-jar
JarData methods throw NPE when jarClasses or rootEntries are null
- Dominant language
- Java
- Stars
- 4
- Forks
- 9
- Avg merge
- 2h 46m
- Merged PRs (30d)
- 3
Description
In `JarData.java`, several delegation methods assume non-null state without guarding:
```java
public boolean isDebugPresent() {
return jarClasses.isDebugPresent(); // NPE if setJarClasses() never called
}
public int getNumRootEntries() {
return rootEntries.size(); // NPE if setRootEntries() never called
}
public int getNumClasses() {
return jarClasses.getClassNames().size(); // NPE if no analysis done
}
```
`jarClasses` and `rootEntries` are set by the analysis pipeline but can be `null` if analysis is skipped or fails (e.g., null manifest, IO error). This makes `JarData` fragile when used outside the expected analysis flow.
**Fix**: Add null checks before delegation, e.g.:
```java
public boolean isDebugPresent() {
return jarClasses != null && jarClasses.isDebugPresent();
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Open JarData.java and inspect the delegation methods that access jarClasses and rootEntries, starting with isDebugPresent(), getNumRootEntries(), and getNumClasses(). Add the requested null guards consistently, then run the relevant project test suite and verify these methods no longer throw when analysis has not initialized those fields.
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
- 78/100