gstreamer-java / gst1-java-core

Java bindings for GStreamer 1.x
GNU Lesser General Public License v3.0
188 stars 72 forks source link

GType.valueOf(long) is not thead safe #260

Closed lafoletc closed 1 year ago

lafoletc commented 1 year ago

Several threads can invoke simultaneously GType.valueOf(long) : several GType instances can be generated for the same long.

Test with gtype1 == gtype2 can fail

PS : GType.valueOf(String) need to be checked too

neilcsmith-net commented 1 year ago

Are there any identity tests except against fundamental types (eg. INVALID) in the existing code? Other than those there should be no expectation that == should be used over equals(). That was always the case until you added the existing caching. Could be changed to use computeIfAbsent() but this is not API for external use anyway.

You're welcome to put in a PR for this, although I cannot guarantee when or if there will be any further releases of this library - focus of our GStreamer work is under review as mentioned on the mailing list.

lafoletc commented 1 year ago

In Structure.setObject(), == is used instead of equals()

neilcsmith-net commented 1 year ago

In Structure.setObject(), == is used instead of equals()

Well, that code is wrong then. It should use equals(). I missed that in reviewing the contribution. Both sides should be updated, Structure and GType.