Closed mathjeff closed 1 year ago
Does it seem right for the spdx-gradle-plugin to access the default model store from several threads concurrently for writing several spdx documents? Is ModelObject() expected to be threadsafe?
Yes - it should be thread-safe. From looking at the code, this does look like an issue with the library. I should be able to resolve this by wrapping the code with enter/exit critical section. I noticed a similar issue in the getObjectPropertyValue
code.
I'll create a pull request to fix.
Created PR #170 to resolve the immediate issue.
In reviewing the code, I found a couple potential issues not addressed in the PR: #169 and #168
@mathjeff let me know if you'd like a release of this fix. Note - it may also require a release of the RDF format store as well.
If it isn't too much effort, it would be great to test this out prior to release since the fix has a (low) probability of a deadlock.
Thanks! I'll get back to you soon about a doing a release if it's not too much trouble - in the meanwhile I'm double-checking that everything else about 1.1.6-SNAPSHOT works well for us ( so far the only other difficulty we've noticed is https://github.com/spdx/Spdx-Java-Library/issues/171 )
@mathjeff I just fixed #171 if you want to pull the latest.
Just FYI - I'll be away from the computer starting Saturday for a week - if you run into any other issues or if you'd like me to spin up a release I'll take care of it the week of the 6th.
Nice - as of https://github.com/spdx/Spdx-Java-Library/pull/170 and https://github.com/spdx/Spdx-Java-Library/pull/172 I'm not noticing any more problems
Having a release on the week of the 6th that would be awesome
Thanks!
It looks like this is resolved, so closing the issue.
@mathjeff - FYI - I just finished a new release of the library and tools-java which includes this PR.
AndroidX is trying out https://github.com/spdx/spdx-gradle-plugin and finding that occasionally
./gradlew spdxSbomForRelease
fails with a stacktrace that looks like this:So far we've only noticed this failure when parallelism is enabled (--max-workers > 1)
I believe that what is happening is that the Gradle plugin is calling
SpdxNoAssertionLicense()
from multiple threads at once, and that the code at https://github.com/spdx/Spdx-Java-Library/blob/da021dffa3c2376f2aa2654863fb000be2aa7d2a/src/main/java/org/spdx/library/model/ModelObject.java#L198 is checking the default model store multiple times for the existence of this object (each time finding it has not been created), and then each thread tries to create it at https://github.com/spdx/Spdx-Java-Library/blob/da021dffa3c2376f2aa2654863fb000be2aa7d2a/src/main/java/org/spdx/library/model/ModelObject.java#L204 and the second creation fails.Does it seem right for the spdx-gradle-plugin to access the default model store from several threads concurrently for writing several spdx documents? Is ModelObject() expected to be threadsafe?
Thanks!