On 12/02/2015 10:37, Nicola Baiocco wrote:
Hi Sergey,

For us would be better that SyncopeClient doesn't expose to final user methods 
that are not thread-safe (at least a comment would be desiderable), final user 
shouldn't know all code details.

Anyway why not insert in SyncopeClient the clients map:
private final Map<Integer, SyncopeClient> clients = Collections.synchronizedMap(new HashMap<Integer, SyncopeClient>());

like used in SyncopeSession(console)?

This one should resolve the problem.

The admin console is an application using the client library, so it is at the same level of your own application: if you like having a synchronized map as reported above, you can do it in your own application.

FYI I have opened SYNCOPE-641 with a simple yet - I believe - effective solution for this problem: Sergey, could you please double check it?

Regards.

-----Messaggio originale-----
Da: Sergey Beryozkin [mailto:[email protected]]
Inviato: mercoledì 11 febbraio 2015 19:01
A: [email protected]
Oggetto: Re: R: Syncope 1.2.1 client concurrent calls

I'd like to clarify.
What happens in this test is
CXF JAXRSClientFactoryBean which represents an individual proxy info is shared 
between multiple threads trying to create a single proxy.
This class has never been guaranteed to be thread-safe.

IMHO a pattern where a thread proxy proxy is created/injected early is what is 
used most of the time.

However I'll look into the code and see if it can create clients concurrently. 
Unfortunately I won't have time to finish it in time for CXF 3.0.4.

I'll update this thread later on

Thanks, Sergey


On 11/02/15 16:29, Sergey Beryozkin wrote:
Hi Nicola
On 11/02/15 16:08, Nicola Baiocco wrote:
Hi Sergey,

you're right, but when SyncopeClientFactoryBean calls
defaultRestClientFactoryBean sets threadSafe property of
RestClientFactoryBean to true ( line 113 of
SyncopeClientFactoryBean.java ).

That flag affects the actual proxy instance only. The utility
construction code is typically not guaranteed to be thread-safe but as
I said Syncope can make it so if really needed (with synchronized blocks).

Why preparing a proxy with

ResourceService service = syncopeClient.get(ResourceService.class);

first and then invoke concurrently on service.get(),

not acceptable ?
Cheers, Sergey
Kind regards.

Nicola Baiocco | Software Developer

Intesys - Via Roveggia 122 A  - 37136 Verona Tel. 045 503663 | Fax
045 503604 [email protected] www.intesys.it

Le informazioni contenute nella presente e-mail e nei suoi allegati
potrebbero essere confidenziali/riservate e sono dirette unicamente
ai destinatari sopra indicati. In caso di ricezione da parte di
persona diversa ? vietato qualunque tipo di divulgazione o copia
anche parziale. Chi riceva questo messaggio per errore ? pregato di
inoltrarlo al mittente e di cancellare questa e-mail.

This e-mail and its attachments may contain confidential/reserved
information and is intended only for the use of the address(es) named
above. If the reader of this message is not the intended recipient of
this message, please note that distribution or copying of this
communication is forbidden. Anyone who receives this communication in
error should return it immediately to the sender and delete the message.
-----Messaggio originale-----
Da: Sergey Beryozkin [mailto:[email protected]]
Inviato: mercoledì 11 febbraio 2015 15:03
A: [email protected]
Oggetto: Re: Syncope 1.2.1 client concurrent calls

Hi

SyncopeClient.getService appears to be a construction call and as
such it is not expected to be thread-safe.
Though I guess it can be made thread-safe if preferred but that would
likely imply passing the user name and password to getService()
method too to avoid having cached CXF client factory beans.
The actual CXF proxies (ResourceService, etc) can be made thread safe
too by having a thread safe flag set on them:

http://cxf.apache.org/docs/jax-rs-client-api.html#JAX-RSClientAPI-Thr
eadSafety


HTH, Sergey

On 11/02/15 11:15, Nicola Baiocco wrote:
Hi all,

we have some problem with multiple cxf calls to Syncope core, seems
that some concurrent problem breaks syncope client calls.

Here a part of the stack trace error:

java.lang.RuntimeException:
java.util.ConcurrentModificationException

                   at
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.createWithValues(
JA
XRSClientFactoryBean.java:341)
~[cxf-rt-rs-client-3.0.2.jar:3.0.2]

                   at
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean.create(JAXRSClien
tF
actoryBean.java:264)
~[cxf-rt-rs-client-3.0.2.jar:3.0.2]

                   at
org.apache.syncope.client.rest.RestClientFactoryBean.createServiceIn
st
ance(RestClientFactoryBean.java:63)
~[syncope-client-1.2.1.jar:na]

                   at
org.apache.syncope.client.SyncopeClient.getService(SyncopeClient.java:
95) ~[syncope-client-1.2.1.jar:na]

We've done a unit test to reproduce the problem, you can find it
here (not the real unit test but an adaptable example):

http://apaste.info/iDr

Hope this will help to have major details.

Kind regards.

http://www.intesys.it/firme/logo_intesys.jpg

*Nicola Baiocco**| Software Developer*

Intesys - Via Roveggia 122 A - 37136 Verona Tel. 045 503663 | Fax
045
503604 [email protected] www.intesys.it
<http://www.intesys.it>

Great Place to Work
<http://www.intesys.it/Partecipazione-dei-dipendenti/>Sito a impatto
zero <http://www.intesys.it/Sostenibilita-Ambientale/>

/Le informazioni contenute nella presente e-mail e nei suoi allegati
potrebbero essere confidenziali/riservate e sono dirette unicamente
ai destinatari sopra indicati. In caso di ricezione da parte di
persona diversa è vietato qualunque tipo di divulgazione o copia anche parziale.
Chi riceva questo messaggio per errore è pregato di inoltrarlo al
mittente e di cancellare questa e-mail. /

/This e-mail and its attachments may contain confidential/reserved
information and is intended only for the use of the address(es)
named above. If the reader of this message is not the intended
recipient of this message, please note that distribution or copying
of this communication is forbidden. Anyone who receives this
communication in error should return it immediately to the sender
and delete the message. /

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/

Reply via email to