You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Pa...@nokia.com on 2008/03/25 20:00:24 UTC

Should ScriptRunner call terminate() on the BSFManager?

Hi,
 
We've recently integrated Jepp (http://jepp.sourceforge.net/) into our
use of Ant via the BSF engine. This is very useful because we use Python
for scripting quite a lot and it allows Python code to be used in full
while also allowing access to Java objects.
 
This has resulted in a Java OOM error, which I suspect is due to this
integration change. There is a comment in the Jepp usage instructions
that close() must be called on the Jep objects. This is done inside the
terminate() method of the BSFJepEngine, which is called by the
BSFManager on all engines. However I cannot see anywhere where
BSFManager.terminate() is called inside ScriptRunner or elsewhere inside
Ant. Should terminate() be called by ScriptRunner(), perhaps in the
finally section in the executeScript method?
 
thanks

paul 

 

Re: Should ScriptRunner call terminate() on the BSFManager?

Posted by Paul King <pa...@asert.com.au>.
Peter Reilly wrote:
> On Tue, Mar 25, 2008 at 8:59 PM, Paul King <pa...@asert.com.au> wrote:
>> Paul.Mackay@nokia.com wrote:
>>  > Hi,
>>  >
>>  > We've recently integrated Jepp (http://jepp.sourceforge.net/) into our
>>  > use of Ant via the BSF engine. This is very useful because we use Python
>>  > for scripting quite a lot and it allows Python code to be used in full
>>  > while also allowing access to Java objects.
>>  >
>>  > This has resulted in a Java OOM error, which I suspect is due to this
>>  > integration change. There is a comment in the Jepp usage instructions
>>  > that close() must be called on the Jep objects. This is done inside the
>>  > terminate() method of the BSFJepEngine, which is called by the
>>  > BSFManager on all engines. However I cannot see anywhere where
>>  > BSFManager.terminate() is called inside ScriptRunner or elsewhere inside
>>  > Ant. Should terminate() be called by ScriptRunner(), perhaps in the
>>  > finally section in the executeScript method?
> 
> Just had a quick look,
>   we should call the terminate method - it is part of the life cycle that
>   we missed.
> 
> Looking at some of the languages:
>   beanshell does not use the  terminate method
>   jruby does
>   rhino does not
>   groovy does not
>   jython does not
>   netrexx does not
>   jacl does not
> 
> so it is not surprising that we missed this.
> 
> The odd thing is that javax.scripting does not seem to have
> a corresponding method and the jruby javax.script engine
> calls the terminate for each invoke method.
> 
> 
>>  Others will be more familiar with the ScriptRunnerXXX classes than me
>>  but in WebTest, its Script task has a keep flag. This might be a useful
>>  concept to have here. Basically the flag allows you to distinguish between
>>  scenarios where you want the binding retained across tasks (and hence
>>  in the scenario above I suspect you don't want terminate() called) and
>>  the case where you want a fresh manager/runner for each run. Again, I
>>  haven't done a complete analysis of what gets called where in Ant at the
>>  moment. Just noting an important use case for WebTest which I know is
>>  in use in the field in many places.
> 
> It should be possible to modify the scripting code in such a way that
> will not affect people that use the code.

OK, that is good to know. Here is a sample of what WebTest does:

<scriptStep keep="true" language="javascript">
    var foo = "bar";
</scriptStep>
<!-- other tasks here ... -->
<storeProperty name="upperfoo" value="#{script:foo.toUpperCase()}"/>
<verifyProperty name="upperfoo" text="BAR"/>

The storeProperty task relies on the same BSFManager being used
with all of its variables intack. Under the covers it is calling
the eval() method in BSFManager. If you get around to making this
change, I'll test out that this stuff still works.

Cheers,
Paul.


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


Re: Should ScriptRunner call terminate() on the BSFManager?

Posted by Peter Reilly <pe...@gmail.com>.
Please enter a bugzilla bug report for this.

It would be nice if the entry contained a tar.gz/or/zip file containing
a example jepp usage - with the relevant/needed jar files in a lib
directory, and better a use of an ant-contrib <for> loop to cause the
problem to happen. and even nicer an simple webtest usage
to ensure that any fix not not impact on projects that extend ant's java
classes. - these are the kind of things that are done when something
like this is fixed - and it is time consuming.

Peter
On Fri, Mar 28, 2008 at 3:23 AM,  <Pa...@nokia.com> wrote:
> Do I need to do anything to follow up on this? How to ensure this fix
>  gets into a future release?
>
>  thanks
>
>  paul
>
>
>
>
>  >-----Original Message-----
>  >From: ext Peter Reilly [mailto:peter.kitt.reilly@gmail.com]
>  >Sent: Tuesday, March 25, 2008 3:52 PM
>  >To: Ant Developers List
>  >Subject: Re: Should ScriptRunner call terminate() on the BSFManager?
>  >
>  >On Tue, Mar 25, 2008 at 8:59 PM, Paul King <pa...@asert.com.au> wrote:
>  >>
>  >> Paul.Mackay@nokia.com wrote:
>  >>  > Hi,
>  >>  >
>  >>  > We've recently integrated Jepp
>  >(http://jepp.sourceforge.net/) into
>  >> our  > use of Ant via the BSF engine. This is very useful because we
>  >> use Python  > for scripting quite a lot and it allows Python code to
>  >> be used in full  > while also allowing access to Java objects.
>  >>  >
>  >>  > This has resulted in a Java OOM error, which I suspect is due to
>  >> this  > integration change. There is a comment in the Jepp usage
>  >> instructions  > that close() must be called on the Jep objects. This
>  >> is done inside the  > terminate() method of the
>  >BSFJepEngine, which is
>  >> called by the  > BSFManager on all engines. However I cannot see
>  >> anywhere where  > BSFManager.terminate() is called inside
>  >ScriptRunner
>  >> or elsewhere inside  > Ant. Should terminate() be called by
>  >> ScriptRunner(), perhaps in the  > finally section in the
>  >executeScript method?
>  >
>  >Just had a quick look,
>  >  we should call the terminate method - it is part of the life
>  >cycle that
>  >  we missed.
>  >
>  >Looking at some of the languages:
>  >  beanshell does not use the  terminate method
>  >  jruby does
>  >  rhino does not
>  >  groovy does not
>  >  jython does not
>  >  netrexx does not
>  >  jacl does not
>  >
>  >so it is not surprising that we missed this.
>  >
>  >The odd thing is that javax.scripting does not seem to have a
>  >corresponding method and the jruby javax.script engine calls
>  >the terminate for each invoke method.
>  >
>  >
>  >>
>  >>  Others will be more familiar with the ScriptRunnerXXX
>  >classes than me
>  >> but in WebTest, its Script task has a keep flag. This might be a
>  >> useful  concept to have here. Basically the flag allows you to
>  >> distinguish between  scenarios where you want the binding retained
>  >> across tasks (and hence  in the scenario above I suspect you don't
>  >> want terminate() called) and  the case where you want a fresh
>  >> manager/runner for each run. Again, I  haven't done a complete
>  >> analysis of what gets called where in Ant at the  moment.
>  >Just noting
>  >> an important use case for WebTest which I know is  in use in
>  >the field in many places.
>  >
>  >It should be possible to modify the scripting code in such a
>  >way that will not affect people that use the code.
>  >
>  >
>  >Peter
>  >>
>  >>  Paul.
>  >>  P.S. For those that aren't aware, WebTest is an Ant extension for
>  >> testing web applications.
>  >>
>  >>
>  >---------------------------------------------------------------------
>  >>  To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org  For
>  >> additional commands, e-mail: dev-help@ant.apache.org
>  >>
>  >>
>  >
>  >---------------------------------------------------------------------
>  >To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For
>  >additional commands, e-mail: dev-help@ant.apache.org
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>  For additional commands, e-mail: dev-help@ant.apache.org
>
>

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


RE: Should ScriptRunner call terminate() on the BSFManager?

Posted by Pa...@nokia.com.
Do I need to do anything to follow up on this? How to ensure this fix
gets into a future release?

thanks

paul
 

>-----Original Message-----
>From: ext Peter Reilly [mailto:peter.kitt.reilly@gmail.com] 
>Sent: Tuesday, March 25, 2008 3:52 PM
>To: Ant Developers List
>Subject: Re: Should ScriptRunner call terminate() on the BSFManager?
>
>On Tue, Mar 25, 2008 at 8:59 PM, Paul King <pa...@asert.com.au> wrote:
>>
>> Paul.Mackay@nokia.com wrote:
>>  > Hi,
>>  >
>>  > We've recently integrated Jepp 
>(http://jepp.sourceforge.net/) into 
>> our  > use of Ant via the BSF engine. This is very useful because we 
>> use Python  > for scripting quite a lot and it allows Python code to 
>> be used in full  > while also allowing access to Java objects.
>>  >
>>  > This has resulted in a Java OOM error, which I suspect is due to 
>> this  > integration change. There is a comment in the Jepp usage 
>> instructions  > that close() must be called on the Jep objects. This 
>> is done inside the  > terminate() method of the 
>BSFJepEngine, which is 
>> called by the  > BSFManager on all engines. However I cannot see 
>> anywhere where  > BSFManager.terminate() is called inside 
>ScriptRunner 
>> or elsewhere inside  > Ant. Should terminate() be called by 
>> ScriptRunner(), perhaps in the  > finally section in the 
>executeScript method?
>
>Just had a quick look,
>  we should call the terminate method - it is part of the life 
>cycle that
>  we missed.
>
>Looking at some of the languages:
>  beanshell does not use the  terminate method
>  jruby does
>  rhino does not
>  groovy does not
>  jython does not
>  netrexx does not
>  jacl does not
>
>so it is not surprising that we missed this.
>
>The odd thing is that javax.scripting does not seem to have a 
>corresponding method and the jruby javax.script engine calls 
>the terminate for each invoke method.
>
>
>>
>>  Others will be more familiar with the ScriptRunnerXXX 
>classes than me  
>> but in WebTest, its Script task has a keep flag. This might be a 
>> useful  concept to have here. Basically the flag allows you to 
>> distinguish between  scenarios where you want the binding retained 
>> across tasks (and hence  in the scenario above I suspect you don't 
>> want terminate() called) and  the case where you want a fresh 
>> manager/runner for each run. Again, I  haven't done a complete 
>> analysis of what gets called where in Ant at the  moment. 
>Just noting 
>> an important use case for WebTest which I know is  in use in 
>the field in many places.
>
>It should be possible to modify the scripting code in such a 
>way that will not affect people that use the code.
>
>
>Peter
>>
>>  Paul.
>>  P.S. For those that aren't aware, WebTest is an Ant extension for  
>> testing web applications.
>>
>>  
>---------------------------------------------------------------------
>>  To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org  For 
>> additional commands, e-mail: dev-help@ant.apache.org
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For 
>additional commands, e-mail: dev-help@ant.apache.org
>
>

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


Re: Should ScriptRunner call terminate() on the BSFManager?

Posted by Peter Reilly <pe...@gmail.com>.
On Tue, Mar 25, 2008 at 8:59 PM, Paul King <pa...@asert.com.au> wrote:
>
> Paul.Mackay@nokia.com wrote:
>  > Hi,
>  >
>  > We've recently integrated Jepp (http://jepp.sourceforge.net/) into our
>  > use of Ant via the BSF engine. This is very useful because we use Python
>  > for scripting quite a lot and it allows Python code to be used in full
>  > while also allowing access to Java objects.
>  >
>  > This has resulted in a Java OOM error, which I suspect is due to this
>  > integration change. There is a comment in the Jepp usage instructions
>  > that close() must be called on the Jep objects. This is done inside the
>  > terminate() method of the BSFJepEngine, which is called by the
>  > BSFManager on all engines. However I cannot see anywhere where
>  > BSFManager.terminate() is called inside ScriptRunner or elsewhere inside
>  > Ant. Should terminate() be called by ScriptRunner(), perhaps in the
>  > finally section in the executeScript method?

Just had a quick look,
  we should call the terminate method - it is part of the life cycle that
  we missed.

Looking at some of the languages:
  beanshell does not use the  terminate method
  jruby does
  rhino does not
  groovy does not
  jython does not
  netrexx does not
  jacl does not

so it is not surprising that we missed this.

The odd thing is that javax.scripting does not seem to have
a corresponding method and the jruby javax.script engine
calls the terminate for each invoke method.


>
>  Others will be more familiar with the ScriptRunnerXXX classes than me
>  but in WebTest, its Script task has a keep flag. This might be a useful
>  concept to have here. Basically the flag allows you to distinguish between
>  scenarios where you want the binding retained across tasks (and hence
>  in the scenario above I suspect you don't want terminate() called) and
>  the case where you want a fresh manager/runner for each run. Again, I
>  haven't done a complete analysis of what gets called where in Ant at the
>  moment. Just noting an important use case for WebTest which I know is
>  in use in the field in many places.

It should be possible to modify the scripting code in such a way that
will not affect
people that use the code.


Peter
>
>  Paul.
>  P.S. For those that aren't aware, WebTest is an Ant extension for
>  testing web applications.
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
>  For additional commands, e-mail: dev-help@ant.apache.org
>
>

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


Re: Should ScriptRunner call terminate() on the BSFManager?

Posted by Paul King <pa...@asert.com.au>.
Paul.Mackay@nokia.com wrote:
> Hi,
>  
> We've recently integrated Jepp (http://jepp.sourceforge.net/) into our
> use of Ant via the BSF engine. This is very useful because we use Python
> for scripting quite a lot and it allows Python code to be used in full
> while also allowing access to Java objects.
>  
> This has resulted in a Java OOM error, which I suspect is due to this
> integration change. There is a comment in the Jepp usage instructions
> that close() must be called on the Jep objects. This is done inside the
> terminate() method of the BSFJepEngine, which is called by the
> BSFManager on all engines. However I cannot see anywhere where
> BSFManager.terminate() is called inside ScriptRunner or elsewhere inside
> Ant. Should terminate() be called by ScriptRunner(), perhaps in the
> finally section in the executeScript method?

Others will be more familiar with the ScriptRunnerXXX classes than me
but in WebTest, its Script task has a keep flag. This might be a useful
concept to have here. Basically the flag allows you to distinguish between
scenarios where you want the binding retained across tasks (and hence
in the scenario above I suspect you don't want terminate() called) and
the case where you want a fresh manager/runner for each run. Again, I
haven't done a complete analysis of what gets called where in Ant at the
moment. Just noting an important use case for WebTest which I know is
in use in the field in many places.

Paul.
P.S. For those that aren't aware, WebTest is an Ant extension for
testing web applications.

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