continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r780207 - in /continuum/branches/continuum-1.3.x: continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/ continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configur...
Date Sat, 30 May 2009 08:51:13 GMT
Author: evenisse
Date: Sat May 30 08:51:12 2009
New Revision: 780207

URL: http://svn.apache.org/viewvc?rev=780207&view=rev
Log:
[CONTINUUM-2204] Fix 'too many open files' error

Modified:
    continuum/branches/continuum-1.3.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
    continuum/branches/continuum-1.3.x/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfiguration.java
    continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
    continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java

Modified: continuum/branches/continuum-1.3.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java?rev=780207&r1=780206&r2=780207&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-base/continuum-configuration/src/main/java/org/apache/continuum/configuration/DefaultContinuumConfiguration.java
Sat May 30 08:51:12 2009
@@ -31,6 +31,7 @@
 import org.apache.continuum.configuration.model.ContinuumConfigurationModel;
 import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Reader;
 import org.apache.continuum.configuration.model.io.xpp3.ContinuumConfigurationModelXpp3Writer;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -114,11 +115,12 @@
     public void reload( File file )
         throws ContinuumConfigurationException
     {
+        FileInputStream fis = null;
         try
         {
+            fis = new FileInputStream( file );
             ContinuumConfigurationModelXpp3Reader configurationXpp3Reader = new ContinuumConfigurationModelXpp3Reader();
-            ContinuumConfigurationModel configuration =
-                configurationXpp3Reader.read( new InputStreamReader( new FileInputStream(
file ) ) );
+            ContinuumConfigurationModel configuration = configurationXpp3Reader.read( new
InputStreamReader( fis ) );
 
             this.generalConfiguration = new GeneralConfiguration();
 
@@ -208,7 +210,13 @@
             log.error( e.getMessage(), e );
             throw new RuntimeException( e.getMessage(), e );
         }
-
+        finally
+        {
+            if ( fis != null )
+            {
+                IOUtil.close( fis );
+            }
+        }
     }
 
     public void save( File file )
@@ -308,6 +316,8 @@
             ContinuumConfigurationModelXpp3Writer writer = new ContinuumConfigurationModelXpp3Writer();
             FileWriter fileWriter = new FileWriter( file );
             writer.write( fileWriter, configurationModel );
+            fileWriter.flush();
+            fileWriter.close();
         }
         catch ( IOException e )
         {

Modified: continuum/branches/continuum-1.3.x/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfiguration.java?rev=780207&r1=780206&r2=780207&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfiguration.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/configuration/DefaultBuildAgentConfiguration.java
Sat May 30 08:51:12 2009
@@ -28,6 +28,7 @@
 import org.apache.continuum.buildagent.model.ContinuumBuildAgentConfigurationModel;
 import org.apache.continuum.buildagent.model.io.xpp3.ContinuumBuildAgentConfigurationModelXpp3Reader;
 import org.apache.continuum.buildagent.model.io.xpp3.ContinuumBuildAgentConfigurationModelXpp3Writer;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.slf4j.Logger;
@@ -82,12 +83,14 @@
     public void reload( File file )
         throws BuildAgentConfigurationException
     {
+        FileInputStream fis = null;
         try
         {
+            fis = new FileInputStream( file );
             ContinuumBuildAgentConfigurationModelXpp3Reader configurationXpp3Reader =
                 new ContinuumBuildAgentConfigurationModelXpp3Reader();
             ContinuumBuildAgentConfigurationModel configuration =
-                configurationXpp3Reader.read( new InputStreamReader( new FileInputStream(
file ) ) );
+                configurationXpp3Reader.read( new InputStreamReader( fis ) );
 
             this.generalBuildAgentConfiguration = new GeneralBuildAgentConfiguration();
             if ( StringUtils.isNotEmpty( configuration.getBuildOutputDirectory() ) )
@@ -113,6 +116,13 @@
             log.error( e.getMessage(), e );
             throw new BuildAgentConfigurationException( e.getMessage(), e );
         }
+        finally
+        {
+            if ( fis != null )
+            {
+                IOUtil.close( fis );
+            }
+        }
     }
 
     public void save()
@@ -148,6 +158,8 @@
                 new ContinuumBuildAgentConfigurationModelXpp3Writer();
             FileWriter fileWriter = new FileWriter( file );
             writer.write( fileWriter, configurationModel );
+            fileWriter.flush();
+            fileWriter.close();
         }
         catch ( IOException e )
         {

Modified: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java?rev=780207&r1=780206&r2=780207&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java
Sat May 30 08:51:12 2009
@@ -48,6 +48,7 @@
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.release.ContinuumReleaseException;
 import org.apache.maven.shared.release.ReleaseResult;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 import org.slf4j.Logger;
@@ -599,10 +600,12 @@
 
         if ( file.exists() )
         {
+            FileInputStream fis = null;
             try
             {
+                fis = new FileInputStream( file );
                 ContinuumPrepareReleasesModelXpp3Reader reader = new ContinuumPrepareReleasesModelXpp3Reader();
-                PreparedReleaseModel model = reader.read( new InputStreamReader( new FileInputStream(
file ) ) );
+                PreparedReleaseModel model = reader.read( new InputStreamReader( fis ) );
 
                 return model.getPreparedReleases();
             }
@@ -616,6 +619,13 @@
                 log.error( e.getMessage(), e );
                 throw new ContinuumReleaseException( e.getMessage(), e );
             }
+            finally
+            {
+                if ( fis != null )
+                {
+                    IOUtil.close( fis );
+                }
+            }
         }
 
         return null;
@@ -670,6 +680,8 @@
             ContinuumPrepareReleasesModelXpp3Writer writer = new ContinuumPrepareReleasesModelXpp3Writer();
             FileWriter fileWriter = new FileWriter( file );
             writer.write( fileWriter, model );
+            fileWriter.flush();
+            fileWriter.close();
         }
         catch ( IOException e )
         {

Modified: continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=780207&r1=780206&r2=780207&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Sat May 30 08:51:12 2009
@@ -55,7 +55,6 @@
 import org.apache.continuum.purge.PurgeConfigurationService;
 import org.apache.continuum.release.distributed.manager.DistributedReleaseManager;
 import org.apache.continuum.repository.RepositoryService;
-import org.apache.continuum.taskqueue.PrepareBuildProjectsTask;
 import org.apache.continuum.taskqueue.manager.TaskQueueManager;
 import org.apache.continuum.taskqueue.manager.TaskQueueManagerException;
 import org.apache.continuum.utils.ProjectSorter;
@@ -103,8 +102,8 @@
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
-import org.codehaus.plexus.taskqueue.TaskQueueException;
 import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -624,14 +623,14 @@
             {
                 if ( parallelBuildsManager.isProjectCurrentlyBeingCheckedOut( projectId )
)
                 {
-                    throw new ContinuumException( "Unable to remove project " + projectId
+ 
-                        " because it is currently being checked out" );
+                    throw new ContinuumException(
+                        "Unable to remove project " + projectId + " because it is currently
being checked out" );
                 }
 
                 if ( parallelBuildsManager.isProjectInAnyCurrentBuild( projectId ) )
                 {
-                    throw new ContinuumException( "Unable to remove project " + projectId
+ 
-                        " because it is currently building" );
+                    throw new ContinuumException(
+                        "Unable to remove project " + projectId + " because it is currently
building" );
                 }
             }
             catch ( BuildManagerException e )
@@ -641,8 +640,8 @@
 
             if ( isProjectInReleaseStage( project ) )
             {
-                throw new ContinuumException( "Unable to remove project " + projectId + 
-                    " because it is in release stage" );
+                throw new ContinuumException(
+                    "Unable to remove project " + projectId + " because it is in release
stage" );
             }
 
             try
@@ -1085,18 +1084,19 @@
         throws ContinuumException
     {
         BuildResult buildResult = getBuildResult( buildId );
-        
+
         // check first if build result is currently being used by a building project
         Project project = buildResult.getProject();
         BuildResult bResult = getLatestBuildResultForProject( project.getId() );
 
         try
         {
-            if ( bResult != null && buildResult.getId() == bResult.getId() &&

-                 parallelBuildsManager.isProjectInAnyCurrentBuild( project.getId() ) )
+            if ( bResult != null && buildResult.getId() == bResult.getId() &&
+                parallelBuildsManager.isProjectInAnyCurrentBuild( project.getId() ) )
             {
-                throw new ContinuumException( "Unable to remove build result because it is
currently being used by" +
-                        "a building project " + project.getId() );
+                throw new ContinuumException(
+                    "Unable to remove build result because it is currently being used by"
+ "a building project " +
+                        project.getId() );
             }
         }
         catch ( BuildManagerException e )
@@ -1658,7 +1658,7 @@
         for ( Project project : projects )
         {
             checkForDuplicateProjectInGroup( projectGroup, project, result );
-          
+
             if ( result.hasErrors() )
             {
                 log.info( result.getErrors().size() + " errors during project add: " );
@@ -2995,13 +2995,14 @@
 
     private String getVersion()
     {
+        InputStream resourceAsStream = null;
         try
         {
             Properties properties = new Properties();
 
             String name = "META-INF/maven/org.apache.continuum/continuum-core/pom.properties";
 
-            InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(
name );
+            resourceAsStream = getClass().getClassLoader().getResourceAsStream( name );
 
             if ( resourceAsStream == null )
             {
@@ -3016,6 +3017,13 @@
         {
             return "unknown";
         }
+        finally
+        {
+            if ( resourceAsStream != null )
+            {
+                IOUtil.close( resourceAsStream );
+            }
+        }
     }
 
     public InstallationService getInstallationService()
@@ -3480,7 +3488,7 @@
         {
             if ( configurationService.isDistributedBuildEnabled() )
             {
-                distributedBuildManager.prepareBuildProjects( projectsBuildDefinitionsMap,
trigger, projectGroupId, 
+                distributedBuildManager.prepareBuildProjects( projectsBuildDefinitionsMap,
trigger, projectGroupId,
                                                               group.getName(), scmRootAddress,
scmRootId );
             }
             else
@@ -3637,13 +3645,13 @@
         return filteredProjectsList;
     }
 
-    private void checkForDuplicateProjectInGroup( ProjectGroup projectGroup, Project projectToCheck,

-                                                   ContinuumProjectBuildingResult result
)
+    private void checkForDuplicateProjectInGroup( ProjectGroup projectGroup, Project projectToCheck,
+                                                  ContinuumProjectBuildingResult result )
     {
         String duplicateProjects = "";
 
         List<Project> projectsInGroup = projectGroup.getProjects();
-        
+
         if ( projectsInGroup == null )
         {
             return;
@@ -3651,10 +3659,10 @@
 
         for ( Project project : (List<Project>) projectGroup.getProjects() )
         {
-            
-            if ( project.getGroupId().equals( projectToCheck.getGroupId() ) && 
-                 project.getArtifactId().equals( projectToCheck.getArtifactId() ) &&
-                 project.getVersion().equals( projectToCheck.getVersion() ) )
+
+            if ( project.getGroupId().equals( projectToCheck.getGroupId() ) &&
+                project.getArtifactId().equals( projectToCheck.getArtifactId() ) &&
+                project.getVersion().equals( projectToCheck.getVersion() ) )
             {
                 result.addError( result.ERROR_DUPLICATE_PROJECTS );
                 return;

Modified: continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java?rev=780207&r1=780206&r2=780207&view=diff
==============================================================================
--- continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
(original)
+++ continuum/branches/continuum-1.3.x/continuum-webapp/src/main/java/org/apache/maven/continuum/web/appareance/DefaultAppareanceConfiguration.java
Sat May 30 08:51:12 2009
@@ -111,7 +111,9 @@
         {
             confFile.getParentFile().mkdirs();
         }
-        writer.write( new FileWriter( confFile ), continuumAppearance );
+        FileWriter fileWriter = new FileWriter( confFile );
+        writer.write( fileWriter, continuumAppearance );
+        fileWriter.close();
         this.footer = footerHtmlContent;
     }
 



Mime
View raw message