You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by pa...@apache.org on 2018/01/29 19:04:04 UTC

svn commit: r1822556 - /turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java

Author: painter
Date: Mon Jan 29 19:04:04 2018
New Revision: 1822556

URL: http://svn.apache.org/viewvc?rev=1822556&view=rev
Log:
Per tv's note, ensure FileInputStream is closed properly under all circumstances. Remove additional test of xmlFile.canRead() as that is already performed in code above this block

Modified:
    turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java

Modified: turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java?rev=1822556&r1=1822555&r2=1822556&view=diff
==============================================================================
--- turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java (original)
+++ turbine/fulcrum/trunk/intake/src/java/org/apache/fulcrum/intake/IntakeServiceImpl.java Mon Jan 29 19:04:04 2018
@@ -776,25 +776,32 @@ public class IntakeServiceImpl extends A
             um.setSchema(schemaFactory.newSchema(schemaURL));
             appDataElements = new HashMap<AppData, File>();
 
-            for (File xmlFile : xmlFiles)
-            {
-            	if ( xmlFile.canRead() )
-            	{
-	                getLogger().debug("Now parsing: " + xmlFile);
-	                
-	                // fix for parallel deployment, passing file directly results in file not found exception
-	                FileInputStream fis = new FileInputStream(xmlFile);
-	                AppData appData = (AppData)um.unmarshal(fis);
-	                fis.close();
-	
-	                if ( appData != null ) {
-	                	appDataElements.put(appData, xmlFile);
-	                	getLogger().debug("Saving appData for " + xmlFile);
-	                }
-            	} else {
-            		throw new Exception("Could not read Intake XML File: " + xmlFile.getPath());
-            	}
-            }
+			for (File xmlFile : xmlFiles) {
+				getLogger().debug("Now parsing: " + xmlFile);
+				FileInputStream fis = null;
+				try {
+					// fix for parallel deployment, passing file directly results in file not found
+					// exception
+					fis = new FileInputStream(xmlFile);
+					AppData appData = (AppData) um.unmarshal(fis);
+
+					if ( fis != null )
+						fis.close();
+
+					appDataElements.put(appData, xmlFile);
+					getLogger().debug("Saving appData for " + xmlFile);
+				} catch (Exception e) {
+					getLogger().debug("Error parsing Intake xml file: " + e.getMessage());
+				} finally {
+					if (fis != null) {
+						try {
+							fis.close();
+						} catch (IOException e) {
+							getLogger().debug("Intake xml file could not be opened");
+						}
+					}
+				}
+			}
 
             getLogger().debug("Parsing took " + (System.currentTimeMillis() - timer));