A Hidden NPE Bug in Current develop Branch
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 564
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 29
Description
I find an npe risk in edu.harvard.iq.dataverse.DatasetDistributor.isEmpty() in develop branch.
What steps does it take to reproduce the issue?
An npe could happen at line 92 of edu.harvard.iq.dataverse.DatasetDistributor.isEmpty()
public boolean isEmpty() {
return // ...
&& (name==null || name.getValue().trim().equals(""))
// ...
}
The expression name.getValue() could return null when no datasetFieldValues and no controlledVocabularyValues provided.
public String getValue() {
if (!datasetFieldValues.isEmpty()) {
// ...
} else if (controlledVocabularyValues != null && !controlledVocabularyValues.isEmpty()) {
// ...
}
return null;
}
- When does this issue occur?
When no datasetFieldValues and no controlledVocabularyValues provided.
-
Which page(s) does it occurs on?
N/A -
What happens?
An NullPointerException will be throwed. -
To whom does it occur (all users, curators, superusers)?
N/A -
What did you expect to happen?
Maybe handle the return value ofgetValuemore carefully?
Which version of Dataverse are you using?
current develop branch.
Any related open or closed issues to this bug report?
N/A
I hope this message could be helpful!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with edu.harvard.iq.dataverse.DatasetDistributor.isEmpty() at line 92 and inspect edu.harvard.iq.dataverse.DatasetField.getValue(), especially the empty datasetFieldValues and controlledVocabularyValues case. Reproduce the condition described in the issue and determine the expected empty-value behavior; done means isEmpty() no longer throws an NPE for that input, with regression coverage if the project’s existing tests support it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100