Return-Path: Delivered-To: apmail-xml-cocoon-cvs-archive@xml.apache.org Received: (qmail 1964 invoked by uid 500); 17 Aug 2002 04:00:58 -0000 Mailing-List: contact cocoon-cvs-help@xml.apache.org; run by ezmlm Precedence: bulk Reply-To: cocoon-dev@xml.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cocoon-cvs@xml.apache.org Received: (qmail 1955 invoked by uid 500); 17 Aug 2002 04:00:58 -0000 Delivered-To: apmail-xml-cocoon2-cvs@apache.org Date: 17 Aug 2002 04:00:57 -0000 Message-ID: <20020817040057.9575.qmail@icarus.apache.org> From: vgritsenko@apache.org To: xml-cocoon2-cvs@apache.org Subject: cvs commit: xml-cocoon2/src/java/org/apache/cocoon/environment/commandline LinkSamplingEnvironment.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N vgritsenko 2002/08/16 21:00:56 Modified: src/java/org/apache/cocoon/environment/commandline Tag: cocoon_2_0_3_branch LinkSamplingEnvironment.java Log: sync with head (explicitly close reader) Revision Changes Path No revision No revision 1.7.2.1 +38 -35 xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java Index: LinkSamplingEnvironment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/LinkSamplingEnvironment.java,v retrieving revision 1.7 retrieving revision 1.7.2.1 diff -u -r1.7 -r1.7.2.1 --- LinkSamplingEnvironment.java 22 Feb 2002 07:03:50 -0000 1.7 +++ LinkSamplingEnvironment.java 17 Aug 2002 04:00:55 -0000 1.7.2.1 @@ -67,33 +67,29 @@ * @version CVS $Id$ */ -public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment -{ +public class LinkSamplingEnvironment extends AbstractCommandLineEnvironment { private boolean skip = false; - public LinkSamplingEnvironment( String uri, - File contextFile, - Map attributes, - Map parameters, - Logger log ) - throws MalformedURLException, IOException - { - super( uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), log ); + public LinkSamplingEnvironment(String uri, + File contextFile, + Map attributes, + Map parameters, + Logger log) + throws MalformedURLException, IOException { + super(uri, Constants.LINK_VIEW, contextFile, new ByteArrayOutputStream(), log); if (getLogger().isDebugEnabled()) { - this.getLogger().debug( "LinkSamplingEnvironment: uri = " + uri ); + this.getLogger().debug("LinkSamplingEnvironment: uri = " + uri); } - this.objectModel.put( ObjectModelHelper.REQUEST_OBJECT, new CommandLineRequest( this, null, uri, null, attributes, parameters ) ); - this.objectModel.put( ObjectModelHelper.RESPONSE_OBJECT, new CommandLineResponse() ); + this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, new CommandLineRequest(this, null, uri, null, attributes, parameters)); + this.objectModel.put(ObjectModelHelper.RESPONSE_OBJECT, new CommandLineResponse()); } /** * Set the ContentType */ - public void setContentType( String contentType ) - { - if ( ! Constants.LINK_CONTENT_TYPE.equals( contentType ) ) - { + public void setContentType(String contentType) { + if (!Constants.LINK_CONTENT_TYPE.equals(contentType)) { this.skip = true; } } @@ -101,24 +97,31 @@ /** * Indicates if other links are present. */ - public Collection getLinks() throws IOException - { + public Collection getLinks() throws IOException { ArrayList list = new ArrayList(); - if ( !skip ) - { - BufferedReader buffer = new BufferedReader( - new InputStreamReader( - new ByteArrayInputStream( - ( ( ByteArrayOutputStream ) super.stream ).toByteArray() - ) - ) - ); - while ( true ) - { - String line = buffer.readLine(); - if ( line == null ) - break; - list.add( line ); + if (!skip) { + BufferedReader buffer = null; + try { + buffer = new BufferedReader( + new InputStreamReader( + new ByteArrayInputStream( + ((ByteArrayOutputStream) super.stream).toByteArray()))); + + while (true) { + String line = buffer.readLine(); + if (line == null) + break; + list.add(line); + } + } finally { + // explictly close the input + if (buffer != null) { + try { + buffer.close(); + buffer = null; + } catch (IOException ignored) { + } + } } } return list; ---------------------------------------------------------------------- In case of troubles, e-mail: webmaster@xml.apache.org To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org For additional commands, e-mail: cocoon-cvs-help@xml.apache.org