On 29/06/2020 14:47, Martynas Jusevičius wrote:
Hi,

I've got a class that is initialized with Jena's registered languages:

And how/when is that called?

I presume you don't use Jena initialization mechanism.

https://jena.apache.org/documentation/notes/system-initialization


     public MediaTypes()
     {
         this(RDFLanguages.getRegisteredLanguages(), UTF8_PARAM);
     }

     protected MediaTypes(Collection<Lang> registered, Map<String,
String> parameters)
     {
         ...
         Iterator<Lang> langIt = registered.iterator();
         while (langIt.hasNext())
         {
             Lang lang = langIt.next();
         ...

After the upgrade to 3.16.0-SNAPSHOT, I am getting a
ConcurrentModificationException on the langIt.next() (worked without
problems with 3.0.1).

Where's the concurrency coming from?
Always? Often? Sometimes?

I've been able to debug that the MediaTypes() constructor is being
called while Jena's languages are not done initializing yet.
The breakpoint at line 256 is from within RDFLanguages.register(Lang
lang); at line 71 is the MediaTypes() constructor.

Does your code initialize Jena explicitly or leave it to requests? That would be the concurrency?

One thing as a general measure: call "JenaSystem.init()" early in statup before requests come in.


...
Breakpoint hit at line 256 in class org.apache.jena.riot.RDFLanguages
by thread http-nio-8080-exec-290.
Breakpoint hit at line 256 in class org.apache.jena.riot.RDFLanguages
by thread http-nio-8080-exec-290.
Breakpoint hit at line 71 in class com.atomgraph.core.MediaTypes by
thread http-nio-8080-exec-290.
Breakpoint hit at line 256 in class org.apache.jena.riot.RDFLanguages
by thread http-nio-8080-exec-290.
Breakpoint hit at line 256 in class org.apache.jena.riot.RDFLanguages
by thread http-nio-8080-exec-290.
...

I cannot get the caller info with NetBeans, but I'm quite sure these
are Jena's internal RDFLanguages.register() calls as I've removed all
calls from our code for now.

This is more of a general static initialization problem I suppose, but
how would you go about addressing it? How does one get all the
languages from RDFLanguages.getRegisteredLanguages()? There's no hook
that would notify completed registration AFAIK.

Thanks.

Martynas

Reply via email to