Closed piotr-gawron closed 4 years ago
Thanks for the bug report. I think the static SBMLReader was added a long time ago to try to speed reading of models but I think it is not necessary any more.
I will do some speed tests and integrate the fix if it is fine.
I have done a fix in master as well as deployed this fix to the maven artefact JSBML-1.5-SNAPSHOT. Could you test it to see if everything is fine now.
I can confirm that the issue is fixed.
Thanks
The problem mentioned in the title is visible when in few threads you try to assign notes (as String) into
AbstractSBase
object. The AbstractSBase can be a model (different model in every thread) or a species. Below is the code that shows the behavior - every thread creates its own model (it's using 20 threads, but if you are lucky you can see it on 2):The problem that I was able to identify is here: https://github.com/sbmlteam/jsbml/blob/master/core/src/org/sbml/jsbml/xml/XMLNode.java#L116 -
SBMLReader
is static, but the class is stateful. So when one thread access the reader it enters some state that is overridden by another thread and as a resultXMLNode.convertStringToXMLNode
can returnnull
instead of meaningful result.The easiest solution would be to use new
SBMLReader
with every call or make all calls to thenotesReader
methods synchronized.