Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Grails HTTPBuilder thread safe?

Is HTTPBuilder in Grails thread safe?

If HTTPBuilder is wired to a Grails service class, will it be safe to use? Or should it be instantiated on every invocation?

There doesn't seem to be any concrete answer as to whether HTTPBuilder in Grails is thread safe or not. I'm inclined to go with non thread safe due to the lack of documentation regarding that particular aspect, but I'd like a definitive answer.

The code seem to indicate it should be ok to handle multiple requests from multiple threads so long as they will go through to the same URL with the same context (headers, authenticators etc.).

like image 652
Thihara Avatar asked Jan 02 '15 03:01

Thihara


1 Answers

Do you mean groovyx.net.http.HTTPBuilder? It has several fields that are modified by calling methods, and there's no synchronization or locking, and no use of thread-safe collections or other classes, so no, it's very much non-thread-safe. Most builders are similarly stateful and should be assumed to not be thread-safe.

like image 126
Burt Beckwith Avatar answered Jan 03 '23 16:01

Burt Beckwith