users@jsonb-spec.java.net

[jsonb-spec users] Re: concurrency capabilities of JsonP/B parts

From: Mark Struberg <struberg_at_yahoo.de>
Date: Thu, 31 Mar 2016 22:57:22 +0200

Great, txs for the pointer!

LieGrue,
strub


> Am 31.03.2016 um 16:11 schrieb Roman Grigoriadi <roman.grigoriadi_at_oracle.com>:
>
> Hi,
>
> yes, Jsonb is thread safe. It's in the javadoc of javax.json.bind.Jsonb type. It is supposed that instance of Jsonb will be passed to some kind of singlton service for being used between requests.
>
> Roman
>
> On 03/25/2016 08:53 AM, Mark Struberg wrote:
>> Hi!
>>
>> While looking at a few tests I asked myself whether those instances are allowed to be used in concurrent requests.
>>
>>
>> JsonbConfig config = new JsonbConfig();
>> config.withAdapters(new AnimalAdapter());
>> Jsonb jsonb = JsonbBuilder.create(config);
>> String json = jsonb.toJson(pojo);
>>
>>
>> Can I e.g. have an @ApplicationScoped CDI bean which creates a single Jsonb instance via @PostConstruct and then reuse this for parallel requests? Or Do I need a fresh JsonBuilder for each thread?
>>
>> Not sure whether I simply missed that in the docs/api javadocs or if it’s not yet defined?
>>
>> txs and LieGrue,
>> strub
>>
>