IQSS / dataverse

Open source research data repository software
http://dataverse.org
Other
882 stars 494 forks source link

DANS-1691 - possible fix for NPE when using IndirectList #10983

Open qqmyers opened 3 weeks ago

qqmyers commented 3 weeks ago

What this PR does / why we need it: DANS is seeing occasional 500 errors from a pre-publication workflow on a dataset with 12K files. The error comes from an NPE after a call the the IndirectList.iterator() method called from our code starting in the editVersionMetadata API call.

  java.lang.NullPointerException: Cannot invoke "org.eclipse.persistence.descriptors.DescriptorEvent.getDescriptor()" because "event" is null
        ...
        at org.eclipse.persistence.indirection.IndirectList.iterator(IndirectList.java:560)
        at edu.harvard.iq.dataverse.FileMetadata.getCategories(FileMetadata.java:221)
        at edu.harvard.iq.dataverse.FileMetadata.getCategoriesByName(FileMetadata.java:253)
        at edu.harvard.iq.dataverse.util.json.JsonPrinter.getFileCategories(JsonPrinter.java:996)
        at edu.harvard.iq.dataverse.util.json.JsonPrinter.json(JsonPrinter.java:698)
        at edu.harvard.iq.dataverse.util.json.JsonPrinter.json(JsonPrinter.java:680)
        at edu.harvard.iq.dataverse.util.json.JsonPrinter.jsonFileMetadatas(JsonPrinter.java:534)
        at edu.harvard.iq.dataverse.util.json.JsonPrinter.json(JsonPrinter.java:474)
        at edu.harvard.iq.dataverse.util.json.JsonPrinter.json(JsonPrinter.java:416)
        at edu.harvard.iq.dataverse.api.Datasets.processDatasetUpdate(Datasets.java:1145)
        at edu.harvard.iq.dataverse.api.Datasets.editVersionMetadata(Datasets.java:1031)
        ...

As we've seen bugs related to the IndirectList class before, this PR simply avoids using iterator by changing the format of the for loop used in FileMetadata.getCategories().

This is a draft PR so DANS can check that this has an effect/fixes the occasional bug.

Which issue(s) this PR closes:

Special notes for your reviewer:

Suggestions on how to test this:

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

Is there a release notes update needed for this change?:

Additional documentation:

coveralls commented 3 weeks ago

Coverage Status

coverage: 21.221% (-0.003%) from 21.224% when pulling 22aa7dc89f716c64f72d6df4bf2dd2dc941e779e on GlobalDataverseCommunityConsortium:DANS_1691 into 6a00ce51cc5072695411c8100238a3165506ba70 on IQSS:develop.