velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erron Austin" <erron.aus...@gmail.com>
Subject Too many open files
Date Wed, 22 Oct 2008 14:43:50 GMT
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();
            }

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message