maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1059276 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli: AccuRevCommandLine.java XppStreamConsumer.java
Date Sat, 15 Jan 2011 09:22:34 GMT
Author: olamy
Date: Sat Jan 15 09:22:32 2011
New Revision: 1059276

URL: http://svn.apache.org/viewvc?rev=1059276&view=rev
Log:
[SCM-588] Filehandle leak in AccuRev provider

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java?rev=1059276&r1=1059275&r2=1059276&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLine.java
Sat Jan 15 09:22:32 2011
@@ -61,12 +61,12 @@ public class AccuRevCommandLine
 
     private Commandline cl = new Commandline();
 
-    private StreamConsumer systemErr;
-
     private StringBuffer commandLines = new StringBuffer();
 
     private StringBuffer errorOutput = new StringBuffer();
 
+    private StreamConsumer systemErr;
+
     private String[] hostArgs = EMPTY_STRING_ARRAY;
 
     private String[] authArgs = EMPTY_STRING_ARRAY;
@@ -247,6 +247,7 @@ public class AccuRevCommandLine
         cl = new Commandline();
         commandLines = new StringBuffer();
         errorOutput = new StringBuffer();
+        systemErr = new ErrorConsumer( getLogger(), errorOutput );
         cl.getShell().setQuotedArgumentsEnabled( true );
         cl.setExecutable( executable );
 
@@ -377,9 +378,7 @@ public class AccuRevCommandLine
 
     public void setLogger( ScmLogger logger )
     {
-
         this.logger = logger;
-        this.systemErr = new ErrorConsumer( logger, errorOutput );
     }
 
     public ScmLogger getLogger()
@@ -572,11 +571,11 @@ public class AccuRevCommandLine
         {
             popArgs = new String[] { "pop", "-v", versionSpec, "-L", basedir.getAbsolutePath(),
"-R" };
         }
-        else //this will BARF for pre 4.9.0, but clients are expected to check AccuRevCapability
before calling.
+        else
+        // this will BARF for pre 4.9.0, but clients are expected to check AccuRevCapability
before calling.
         {
             popArgs = new String[] { "pop", "-v", versionSpec, "-L", basedir.getAbsolutePath(),
"-t", tranSpec, "-R" };
         }
-       
 
         List<File> poppedFiles = new ArrayList<File>();
         return executeCommandLine( basedir, popArgs, elements, FileConsumer.POPULATE_PATTERN,
poppedFiles ) ? poppedFiles

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java?rev=1059276&r1=1059275&r2=1059276&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-accurev/src/main/java/org/apache/maven/scm/provider/accurev/cli/XppStreamConsumer.java
Sat Jan 15 09:22:32 2011
@@ -20,6 +20,7 @@ package org.apache.maven.scm.provider.ac
  */
 
 import java.io.IOException;
+import java.io.Reader;
 import java.io.Writer;
 import java.nio.channels.Channels;
 import java.nio.channels.Pipe;
@@ -63,6 +64,8 @@ public abstract class XppStreamConsumer
 
     private int lineCount = 0;
 
+    private Reader reader;
+
     public XppStreamConsumer( ScmLogger logger )
     {
 
@@ -73,9 +76,10 @@ public abstract class XppStreamConsumer
             Pipe p = Pipe.open();
             SinkChannel sink = p.sink();
             SourceChannel source = p.source();
-
             writer = Channels.newWriter( sink, Charset.defaultCharset().name() );
-            parser.setInput( Channels.newReader( source, Charset.defaultCharset().name()
) );
+            reader = Channels.newReader( source, Charset.defaultCharset().name() );
+            parser.setInput( reader );
+
         }
         catch ( Exception e )
         {
@@ -121,6 +125,16 @@ public abstract class XppStreamConsumer
         {
             synchronized ( this )
             {
+                
+                try
+                {
+                    reader.close();
+                }
+                catch ( IOException e )
+                {
+                    getLogger().warn( "Error closing pipe reader", e );
+                }
+                
                 complete = true;
                 this.notifyAll();
             }



Mime
View raw message