Skip to content

Commit

Permalink
possible fix for NPE iwhen using IndirectList
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Oct 30, 2024
1 parent 64ac076 commit 23569a3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/FileMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,13 @@ public List<DataFileCategory> getCategories() {
*/
if (!(fileCategories instanceof ArrayList)) {
List<DataFileCategory> newDFCs = new ArrayList<DataFileCategory>();
for (DataFileCategory fdc : fileCategories) {
newDFCs.add(fdc);
/* DANS has reported intermittent errors in this call related to using
* an IndirectList.iterator when using a for(DataFileCategory fdc:fileDataCategories) loop
* (which results in an NPE in org.exlipse.persistence.descriptors.DescriptorEvent.getDescriptor())
* So we switch to using size() and get():
*/
for (int i=0;i< fileCategories.size(); i++) {
newDFCs.add(fileCategories.get(i));
}
setCategories(newDFCs);
}
Expand Down

0 comments on commit 23569a3

Please sign in to comment.