groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacopo Cappellato <>
Subject Thread safety and OptionBuilder
Date Sat, 02 May 2015 10:51:47 GMT
Hi all,

in the GroovyMain class there is the following code:

 * Build the options parser.  Has to be synchronized because of the way Options are constructed.
 * @return an options parser.
private static synchronized Options buildOptions() {
    Options options = new Options();

The JavaDoc comment says:

"Has to be synchronized because of the way Options are constructed."

but unfortunately this is not enough to make the Groovy code thread safe.
In fact the current version of Commons CLI used by Groovy is 1.2, which is the latest stable
release, and in this version the OptionBuilder class is clearly not meant to be used by more
than one thread (there are several static fields modified by the builder methods); the issue
has been reported a few times (e.g. and has
been fixed by deprecating the class in favor of a new Option.builder() method:

Unfortunately I don't know if Commons-CLI 1.3 will be released soon (1.2. was released 2 years
ago). And the OptionBuilder class is used in a few classes in Groovy.

My question is: is this a concern/known issue for Groovy? what is the best way to address
the issue? Should we get in touch with the Commons CLI community to know more about their
plans or should me look for a different approach? With this information I will try to help
to move in the direction you feel is the best.



View raw message