[seam-commits] Seam SVN: r15240 - branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Oct 9 10:34:39 EDT 2012


Author: manaRH
Date: 2012-10-09 10:34:38 -0400 (Tue, 09 Oct 2012)
New Revision: 15240

Modified:
   branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java
   branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java
   branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java
Log:
fixed some resource leaks in seam-cdk-helper

Modified: branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java
===================================================================
--- branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java	2012-10-09 14:06:30 UTC (rev 15239)
+++ branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ConverterGenerator.java	2012-10-09 14:34:38 UTC (rev 15240)
@@ -40,20 +40,30 @@
       }
    }
 
-   private boolean fileIsConverterSource(File file) throws FileNotFoundException
-   {
-      if (file.getName().endsWith(".java"))
-      {
-         Scanner scanner = new Scanner(file);
-         String find = scanner.findWithinHorizon("@FacesConverter", 0);
-         if (find != null)
-         {
-            log.info("Identified " + file.getName() + " as Converter source code");
-            return true;
-         }
-      }
-      return false;
-   }
+	private boolean fileIsConverterSource(File file)
+			throws FileNotFoundException 
+	{
+		
+		if (file.getName().endsWith(".java")) 
+		{
+			Scanner scanner = new Scanner(file);
+			String find = scanner.findWithinHorizon("@FacesConverter", 0);
+			try 
+			{
+				if (find != null) 
+				{
+					log.info("Identified " + file.getName()
+							+ " as Converter source code");
+					return true;
+				}
+			} 
+			finally 
+			{
+				scanner.close();
+			}
+		}
+		return false;
+	}
 
    public void generateConverters() throws Exception
    {
@@ -87,10 +97,17 @@
          {
             Scanner scanner = new Scanner(f);
             String find = scanner.findWithinHorizon(classFromSource, 0);
-            if (find != null)
+            try
             {
-               return f;
+               if (find != null)
+               {
+                  return f;
+               }
             }
+            finally
+            {
+               scanner.close();
+            }
          }
       }
       return null;

Modified: branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java
===================================================================
--- branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java	2012-10-09 14:06:30 UTC (rev 15239)
+++ branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/ValidatorGenerator.java	2012-10-09 14:34:38 UTC (rev 15240)
@@ -49,11 +49,18 @@
       {
          Scanner scanner = new Scanner(file);
          String find = scanner.findWithinHorizon("<validator>", 0);
-         if (find != null)
+         try
          {
-            log.info("Identified " + file.getName() + " as Validator XML");
-            return true;
+	         if (find != null)
+	         {
+	            log.info("Identified " + file.getName() + " as Validator XML");
+	            return true;
+	         }
          }
+         finally
+         {
+             scanner.close();
+         }
       }
       return false;
    }

Modified: branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java
===================================================================
--- branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java	2012-10-09 14:06:30 UTC (rev 15239)
+++ branches/enterprise/WFK-2_1/seam-cdk-helper/src/main/java/org/jboss/seam/maven/helper/XMLGenerator.java	2012-10-09 14:34:38 UTC (rev 15240)
@@ -126,7 +126,7 @@
       log.info("Updating " + outXML);
       FileOutputStream fos = new FileOutputStream(outXML);
       fos.write(content.getBytes());
-
+      fos.close();
    }
 
    public void updateFile(File outXML, List<Element> tags) throws Exception



More information about the seam-commits mailing list