You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Fell, Simon" <sf...@ebay.com.INVALID> on 2020/01/14 22:36:26 UTC

TypeMapper thread safety

Hi,

I was looking at org.apache.jena.datatypes.TypeMapper and noticed that it’s a shared instance, but it manages state in regular old HashMaps. Given that getSafeTypeByName can end up calling registerDatatype, I don’t think its safe to assume that these hashmaps are only written at construction/reset time. Seems like these should be swapped to ConcurentHashMaps.

Thoughts? I’d be happy to put together a patch for this.

Cheers
Simon

Re: TypeMapper thread safety

Posted by Andy Seaborne <an...@apache.org>.
Excellent!

On 22/01/2020 18:35, Fell, Simon wrote:
> PR Submitted https://github.com/apache/jena/pull/676
> 
> Cheers
> Simon
> 
> On 1/15/20, 2:11 AM, "Andy Seaborne" <an...@apache.org> wrote:
> 
>      Hi Simon,
>      
>      Makes sense to me to make that change - please do send in a patch.
>      
>           Andy
>      
>      On 14/01/2020 22:36, Fell, Simon wrote:
>      > Hi,
>      >
>      > I was looking at org.apache.jena.datatypes.TypeMapper and noticed that it’s a shared instance, but it manages state in regular old HashMaps. Given that getSafeTypeByName can end up calling registerDatatype, I don’t think its safe to assume that these hashmaps are only written at construction/reset time. Seems like these should be swapped to ConcurentHashMaps.
>      >
>      > Thoughts? I’d be happy to put together a patch for this.
>      >
>      > Cheers
>      > Simon
>      >
>      
> 

Re: TypeMapper thread safety

Posted by "Fell, Simon" <sf...@ebay.com.INVALID>.
PR Submitted https://github.com/apache/jena/pull/676

Cheers
Simon

On 1/15/20, 2:11 AM, "Andy Seaborne" <an...@apache.org> wrote:

    Hi Simon,
    
    Makes sense to me to make that change - please do send in a patch.
    
         Andy
    
    On 14/01/2020 22:36, Fell, Simon wrote:
    > Hi,
    > 
    > I was looking at org.apache.jena.datatypes.TypeMapper and noticed that it’s a shared instance, but it manages state in regular old HashMaps. Given that getSafeTypeByName can end up calling registerDatatype, I don’t think its safe to assume that these hashmaps are only written at construction/reset time. Seems like these should be swapped to ConcurentHashMaps.
    > 
    > Thoughts? I’d be happy to put together a patch for this.
    > 
    > Cheers
    > Simon
    > 
    


Re: TypeMapper thread safety

Posted by Andy Seaborne <an...@apache.org>.
Hi Simon,

Makes sense to me to make that change - please do send in a patch.

     Andy

On 14/01/2020 22:36, Fell, Simon wrote:
> Hi,
> 
> I was looking at org.apache.jena.datatypes.TypeMapper and noticed that it’s a shared instance, but it manages state in regular old HashMaps. Given that getSafeTypeByName can end up calling registerDatatype, I don’t think its safe to assume that these hashmaps are only written at construction/reset time. Seems like these should be swapped to ConcurentHashMaps.
> 
> Thoughts? I’d be happy to put together a patch for this.
> 
> Cheers
> Simon
>