NoSuchElementException from VariableDS in multi-threaded environment

Versions impacted by the bug

5.7.0, 5.8.0, 5.9.0

What went wrong?

Intermittent NoSuchElementException errors thrown in VariableDS in a multithreaded environment.

Relevant stack trace

java.util.NoSuchElementException
at java.base/java.lang.CompoundEnumeration.nextElement(ClassLoader.java:2770)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass(ServiceLoader.java:1213)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1228)
at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1273)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1393)
at ucar.nc2.dataset.VariableDS.createEnhancements(VariableDS.java:975)
at ucar.nc2.dataset.VariableDS.enhance(VariableDS.java:238)
at ucar.nc2.dataset.NetcdfDataset.enhance(NetcdfDataset.java:532)
at ucar.nc2.dataset.NetcdfDataset.<init>(NetcdfDataset.java:1148)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:491)
at ucar.nc2.dataset.NetcdfDataset.acquireDataset(NetcdfDataset.java:640)
at ucar.nc2.dataset.NetcdfDataset.acquireDataset(NetcdfDataset.java:597)
...

Relevant log messages

No response

If you have an example file that you can share, please attach it to this issue.

If so, may we include it in our test datasets to help ensure the bug does not return once fixed?
Note: the test datasets are publicly accessible without restriction.

N/A

Code of Conduct

  • I agree to follow the UCAR/Unidata Code of Conduct