velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adrian Tarau <adrian.ta...@gmail.com>
Subject Re: Too many open files
Date Wed, 22 Oct 2008 15:17:12 GMT
Sorry, you should start here : 
http://blogs.sun.com/nbprofiler/entry/profiling_with_visualvm_part_1


Erron Austin wrote:
> We are experiencing a "too many open files error" in our application running
> on Linux using Velocity Engine 1.5 and Velocity Tools 1.4.  Doing a Google
> search shows the way to correct the issue is to increase the number of
> allowed file handlers. However, I also see where the culprit for the issue
> arising any way besides loads may be streams not being closed.
> Question 1: Has anyone else run into this issue?
> Question 2: Should the following code snippet be refactored from
> (org.apache.velocity.Template):
> try
>             {
>                 BufferedReader br = new BufferedReader( new
> InputStreamReader( is, encoding ) );
>                 data = rsvc.parse( br, name);
>                 initDocument();
>                 return true;
>             }
>             catch( UnsupportedEncodingException  uce )
>             {
>                 String msg = "Template.process : Unsupported input encoding
> : " + encoding
>                 + " for template " + name;
>
>                 errorCondition  = new ParseErrorException( msg );
>                 throw errorCondition;
>             }
>             catch ( ParseException pex )
>             {
>                 /*
>                  *  remember the error and convert
>                  */
>                 errorCondition =  new ParseErrorException( pex );
>                 throw errorCondition;
>             }
>             catch ( TemplateInitException pex )
>             {
>                 errorCondition = new ParseErrorException( pex );
>                 throw errorCondition;
>             }
>             /**
>              * pass through runtime exceptions
>              */
>             catch( RuntimeException e )
>             {
>                 throw new RuntimeException("Exception thrown processing
> Template "+getName(), e);
>             }
>             finally
>             {
>                 /*
>                  *  Make sure to close the inputstream when we are done.
>                  */
>                 is.close();
>             }
>
> to
>
> try {
>                 isr = new InputStreamReader(is, encoding);
>                 br = new BufferedReader(isr);
>                 data = rsvc.parse(br, name);
>                 initDocument();
>                 return true;
>             }
>             catch (UnsupportedEncodingException uce) {
>                 String msg = "Template.process : Unsupported input encoding
> : " + encoding + " for template " + name;
>
>                 errorCondition = new ParseErrorException(msg);
>                 throw errorCondition;
>             }
>             catch (ParseException pex) {
>                 /*
>                  *  remember the error and convert
>                  */
>                 errorCondition = new ParseErrorException(pex);
>                 throw errorCondition;
>             }
>             catch (TemplateInitException pex) {
>                 errorCondition = new ParseErrorException(pex);
>                 throw errorCondition;
>             }
>             /**
>              * pass through runtime exceptions
>              */
>             catch (RuntimeException e) {
>                 throw new RuntimeException("Exception thrown processing
> Template " + getName(), e);
>             }
>             finally {
>                 /*
>                  *  Make sure to close the inputstream when we are done.
>                  */
>                 is.close();
>                 br.close();
>                 isr.close();
>             }
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message