ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mattf <matt...@hotmail.com>
Subject Re: How do I share data between custom Ant tasks?
Date Mon, 25 Oct 2010 23:53:01 GMT

I think there are several problems here, but the bottom like is: be upfront
about sharing data, hidden shared data may not give the user the tool they
expect.<p/>

In the following:
<pre>
public Integer get_bigdata() {
        if (_static_bigdata == null) {
            log("alloc");  // from ant Task class
            _static_bigdata = new Integer(0);
        }
        return _static_bigdata;
    }
</pre>

You have unsynchronized lazy init, the "if" block should be synchronized.
(Or use
<pre>
static {
_static_bigdata = new Integer(0);
};
</pre>
for load time init).

That may not solve your problem, but static lazy init blocks should be lock
protected.
<p/>
On your other question, yes if the class is reloaded; the static
initializers will run again.  Consider placing your data into properties. 
This would also allow the user to control the shared data block.

-- 
View this message in context: http://ant.1045680.n5.nabble.com/How-do-I-share-data-between-custom-Ant-tasks-tp3235670p3236384.html
Sent from the Ant - Dev mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message