Index: test/edu/ucsb/nceas/metacat/dataone/RegisterDOITest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/dataone/RegisterDOITest.java	(revision 8303)
+++ test/edu/ucsb/nceas/metacat/dataone/RegisterDOITest.java	(revision 8304)
@@ -35,6 +35,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
+import org.apache.commons.io.IOUtils;
 import org.dataone.client.ObjectFormatCache;
 import org.dataone.configuration.Settings;
 import org.dataone.service.types.v1.Identifier;
@@ -144,12 +145,15 @@
 		String emlFile = "test/tao.14563.1.xml";
 		InputStream content = null;
 		try {
-			content = new FileInputStream(emlFile);
+		    content = new FileInputStream(emlFile);
+		    testMintAndCreateDOI(content);
+		    content.close(); 
 		} catch (FileNotFoundException e) {
 			e.printStackTrace();
 			fail(e.getMessage());
+		} finally {
+		    IOUtils.closeQuietly(content);
 		}
-		testMintAndCreateDOI(content);
 	}
 	
 	/**
@@ -267,27 +271,31 @@
 			InputStream content = null;
 			try {
 				content = new FileInputStream(emlFile);
+	            
+	            // create the initial version without DOI
+	            SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), null);
+	            sysmeta.setFormatId(ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0").getFormatId());
+	            Identifier pid = MNodeService.getInstance(request).create(session, guid, content, sysmeta);
+	            assertEquals(guid.getValue(), pid.getValue());
+
+	            // now publish it
+	            Identifier publishedIdentifier = MNodeService.getInstance(request).publish(session, pid);
+	            
+	            // check for the metadata explicitly, using ezid service
+	            EZIDService ezid = new EZIDService(ezidServiceBaseUrl);
+	            ezid.login(ezidUsername, ezidPassword);
+	            HashMap<String, String> metadata = ezid.getMetadata(publishedIdentifier.getValue());
+	            assertNotNull(metadata);
+	            assertTrue(metadata.containsKey(DataCiteProfile.TITLE.toString()));
+	            content.close();
 			} catch (FileNotFoundException e) {
 				e.printStackTrace();
 				fail(e.getMessage());
+			} finally {
+			    IOUtils.closeQuietly(content);
 			}
-			
-			// create the initial version without DOI
-			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), null);
-	        sysmeta.setFormatId(ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0").getFormatId());
-			Identifier pid = MNodeService.getInstance(request).create(session, guid, content, sysmeta);
-			assertEquals(guid.getValue(), pid.getValue());
 
-			// now publish it
-			Identifier publishedIdentifier = MNodeService.getInstance(request).publish(session, pid);
 			
-			// check for the metadata explicitly, using ezid service
-			EZIDService ezid = new EZIDService(ezidServiceBaseUrl);
-			ezid.login(ezidUsername, ezidPassword);
-			HashMap<String, String> metadata = ezid.getMetadata(publishedIdentifier.getValue());
-			assertNotNull(metadata);
-			assertTrue(metadata.containsKey(DataCiteProfile.TITLE.toString()));
-			
 		} catch (Exception e) {
 			e.printStackTrace();
 			fail("Unexpected error: " + e.getMessage());
Index: test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java
===================================================================
--- test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java	(revision 8303)
+++ test/edu/ucsb/nceas/metacattest/client/MetacatClientTest.java	(revision 8304)
@@ -113,11 +113,15 @@
      */
     public void setUp()
     {
+        FileInputStream fis = null;
         try {
-        	FileInputStream fis = new FileInputStream(testfile);
+        	fis = new FileInputStream(testfile);
             testdocument = IOUtils.toString(fis);
+            fis.close();
         } catch (IOException ioe) {
             fail("Can't read test data to run the test: " + testfile);
+        } finally {
+            IOUtils.closeQuietly(fis);
         }
 
         try {
@@ -390,33 +394,35 @@
      * Test to get access control part of a document
      */
     public void getAccessControl() {
-      try {
-        FileInputStream fis = new FileInputStream(testEMLWithAccess);
-        String document = IOUtils.toString(fis);
-        String identifier = newdocid + ".1";
-        m.login(username, password);
-        String response = m.insert(identifier,
-                new StringReader(document), null);
-        assertTrue(response.indexOf("<success>") != -1);
-        assertTrue(response.indexOf(identifier) != -1);
-        response = m.getAccessControl(identifier);
-        //System.out.println("reponse is "+reponse);
-        assertTrue(response.indexOf("<permission>read</permission>") != -1);
-        assertTrue(response.indexOf("<principal>public</principal>") != -1);
-    } catch (MetacatAuthException mae) {
-        fail("Authorization failed:\n" + mae.getMessage());
-    } catch (MetacatInaccessibleException mie) {
-        fail("Metacat Inaccessible:\n" + mie.getMessage());
-    } catch (InsufficientKarmaException ike) {
-        assertTrue(1 == 1);
-        fail("Insufficient karma:\n" + ike.getMessage());
-    } catch (MetacatException me) {
-        fail("Metacat Error:\n" + me.getMessage());
-    } catch (Exception e) {
-        fail("General exception:\n" + e.getMessage());
+        FileInputStream fis = null;
+        try {
+            fis = new FileInputStream(testEMLWithAccess);
+            String document = IOUtils.toString(fis);
+            String identifier = newdocid + ".1";
+            m.login(username, password);
+            String response = m.insert(identifier, new StringReader(document), null);
+            assertTrue(response.indexOf("<success>") != -1);
+            assertTrue(response.indexOf(identifier) != -1);
+            response = m.getAccessControl(identifier);
+            //System.out.println("reponse is "+reponse);
+            assertTrue(response.indexOf("<permission>read</permission>") != -1);
+            assertTrue(response.indexOf("<principal>public</principal>") != -1);
+            fis.close();
+        } catch (MetacatAuthException mae) {
+            fail("Authorization failed:\n" + mae.getMessage());
+        } catch (MetacatInaccessibleException mie) {
+            fail("Metacat Inaccessible:\n" + mie.getMessage());
+        } catch (InsufficientKarmaException ike) {
+            assertTrue(1 == 1);
+            fail("Insufficient karma:\n" + ike.getMessage());
+        } catch (MetacatException me) {
+            fail("Metacat Error:\n" + me.getMessage());
+        } catch (Exception e) {
+            fail("General exception:\n" + e.getMessage());
+        } finally {
+            IOUtils.closeQuietly(fis);
+        }
     }
-     
-  }
     
     /**
      * Test to get access control part of a document
Index: lib/style/skins/kepler/keplerAuthNameSpace.jsp
===================================================================
--- lib/style/skins/kepler/keplerAuthNameSpace.jsp	(revision 8303)
+++ lib/style/skins/kepler/keplerAuthNameSpace.jsp	(revision 8304)
@@ -83,6 +83,7 @@
 					ObjectOutputStream oos = new ObjectOutputStream(os);
 					oos.writeObject( inc );
 					oos.flush();
+					oos.close();
 
 					/*
 					 * Print out the incremented Integer as the namespace output
Index: src/edu/ucsb/nceas/metacat/MetacatHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 8304)
@@ -65,6 +65,7 @@
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.input.XmlStreamReader;
 import org.apache.log4j.Logger;
 import org.dataone.service.types.v1.Identifier;
@@ -1279,8 +1280,9 @@
                         out.write(buf, 0, b);
                         b = fin.read(buf);
                     }
+                    fin.close();
                 } finally {
-                    if (fin != null) fin.close();
+                    IOUtils.closeQuietly(fin);
                 }
                 
             } else {
@@ -1549,8 +1551,9 @@
                             zout.write(buf, 0, b);
                             b = fin.read(buf);
                         }
+                        fin.close();
                     } finally {
-                        if (fin != null) fin.close();
+                        IOUtils.closeQuietly(fin);
                     }
                     zout.closeEntry();
                     
Index: src/edu/ucsb/nceas/metacat/util/ResponseUtil.java
===================================================================
--- src/edu/ucsb/nceas/metacat/util/ResponseUtil.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/util/ResponseUtil.java	(revision 8304)
@@ -37,6 +37,7 @@
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 
 import edu.ucsb.nceas.metacat.shared.BaseException;
@@ -113,6 +114,8 @@
 	public static void writeFileToOutput(HttpServletResponse response, String fileDir, String fileName, int bufferSize)
 			throws MetacatUtilException {
 		String filePath = "";
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
 		try {
 			filePath = fileDir + FileUtil.getFS() + fileName;
 			
@@ -120,8 +123,8 @@
 			String shortFileName = fileName.substring(lastFileSep + 1, fileName.length());
 			response.setHeader("Content-Disposition", "attachment; filename=\"" + shortFileName + "\"");
 			
-			InputStream inputStream = new FileInputStream(filePath);
-			OutputStream outputStream = response.getOutputStream();
+			inputStream = new FileInputStream(filePath);
+			outputStream = response.getOutputStream();
 			
 			byte[] byteBuffer = new byte[bufferSize]; 
 
@@ -128,7 +131,9 @@
 			int b = 0;
 			while ((b = inputStream.read(byteBuffer)) != -1) {
 				outputStream.write(byteBuffer, 0, b);
-			}	
+			}
+			outputStream.close();
+			inputStream.close();
 			
 		} catch (FileNotFoundException fnfe) {
 			throw new MetacatUtilException("Error finding file: " + filePath 
@@ -136,6 +141,9 @@
 		} catch (IOException ioe) {
 			throw new MetacatUtilException("I/O Error when writing: " + filePath 
 					+ "  to output");
+		} finally {
+		    IOUtils.closeQuietly(inputStream);
+		    IOUtils.closeQuietly(outputStream);
 		}
 	}
 	
Index: src/edu/ucsb/nceas/metacat/DBQuery.java
===================================================================
--- src/edu/ucsb/nceas/metacat/DBQuery.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/DBQuery.java	(revision 8304)
@@ -60,6 +60,7 @@
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.log4j.Logger;
 import org.dataone.service.exceptions.NotImplemented;
@@ -2326,13 +2327,16 @@
             while (b != -1) {
                 zipOut.write(buf, 0, b);
                 b = fin.read(buf);
-            }//while
+            }
+            fin.close();
             zipOut.closeEntry();
         }//try
         catch (IOException ioe) {
             logMetacat.error("DBQuery.addDataFileToZipOutputStream - I/O error: "
                     + ioe.getMessage());
-        }//catch
+        } finally {
+            IOUtils.closeQuietly(fin);
+        }
     }//addDataFileToZipOutputStream()
 
     /**
Index: src/edu/ucsb/nceas/metacat/oaipmh/provider/server/OAIHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/oaipmh/provider/server/OAIHandler.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/oaipmh/provider/server/OAIHandler.java	(revision 8304)
@@ -36,6 +36,7 @@
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 import org.apache.log4j.PropertyConfigurator;
 
@@ -358,6 +359,7 @@
       TransformerFactory tFactory = TransformerFactory.newInstance();
       Transformer transformer = tFactory.newTransformer(xslSource);
       attributes.put("OAIHandler.transformer", transformer);
+      is.close();
     }
 
     return attributes;
@@ -524,76 +526,72 @@
    *              there was a problem with initialization
    */
   //public void init_debug(ServletConfig config) throws ServletException {
-  public void init(ServletConfig config) throws ServletException {
-    super.init(config);
+    public void init(ServletConfig config) throws ServletException {
+        super.init(config);
 
-    if (isIntegratedWithMetacat()) {
-      try {
-        PropertyService.getInstance();
-      } 
-      catch (ServiceException se) {
-        System.err.println("Error in loading properties: " + se.getMessage());
-      }
-    }
-    
-    ServletContext servletContext = config.getServletContext();
-    String configDirPath = servletContext.getRealPath(CONFIG_DIR);
-    String configPath = configDirPath + "/" + CONFIG_NAME;
+        if (isIntegratedWithMetacat()) {
+            try {
+                PropertyService.getInstance();
+            } catch (ServiceException se) {
+                System.err.println("Error in loading properties: " + se.getMessage());
+            }
+        }
 
-    // Initialize the properties file for log4j
-    String log4jPath = configDirPath + "/" + LOG4J_NAME;
-    PropertyConfigurator.configureAndWatch(log4jPath);
-    
-    // Initialize the directory path to the crosswalk XSLT files
-    String xsltDirPath = servletContext.getRealPath(XSLT_DIR);
-    Eml2oai_dc.setDirPath(xsltDirPath);
+        ServletContext servletContext = config.getServletContext();
+        String configDirPath = servletContext.getRealPath(CONFIG_DIR);
+        String configPath = configDirPath + "/" + CONFIG_NAME;
 
-    try {
-      HashMap attributes = null;
-      Properties properties = null;
-      InputStream in;
+        // Initialize the properties file for log4j
+        String log4jPath = configDirPath + "/" + LOG4J_NAME;
+        PropertyConfigurator.configureAndWatch(log4jPath);
 
-      try {
-        log.debug("configPath=" + configPath);
-        in = new FileInputStream(configPath);
-      } 
-      catch (FileNotFoundException e) {
-        log.debug("configPath not found. Try the classpath: " + configPath);
-        Thread thread = Thread.currentThread();
-        ClassLoader classLoader = thread.getContextClassLoader();
-        in = classLoader.getResourceAsStream(configPath);
-      }
+        // Initialize the directory path to the crosswalk XSLT files
+        String xsltDirPath = servletContext.getRealPath(XSLT_DIR);
+        Eml2oai_dc.setDirPath(xsltDirPath);
+        InputStream in = null;
 
-      if (in != null) {
-        log.debug("configPath '" + configPath + "' found. Loading properties");
-        properties = new Properties();
-        properties.load(in);
-        attributes = getAttributes(properties);
-      }
+        try {
+            HashMap attributes = null;
+            Properties properties = null;
+            
+            try {
+                log.debug("configPath=" + configPath);
+                in = new FileInputStream(configPath);
+            } catch (FileNotFoundException e) {
+                log.debug("configPath not found. Try the classpath: " + configPath);
+                Thread thread = Thread.currentThread();
+                ClassLoader classLoader = thread.getContextClassLoader();
+                in = classLoader.getResourceAsStream(configPath);
+            }
 
-      attributesMap.put("global", attributes);
+            if (in != null) {
+                log.debug("configPath '" + configPath + "' found. Loading properties");
+                properties = new Properties();
+                properties.load(in);
+                attributes = getAttributes(properties);
+            }
+
+            attributesMap.put("global", attributes);
+            in.close();
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+            throw new ServletException(e.getMessage());
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            throw new ServletException(e.getMessage());
+        } catch (IllegalArgumentException e) {
+            e.printStackTrace();
+            throw new ServletException(e.getMessage());
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw new ServletException(e.getMessage());
+        } catch (Throwable e) {
+            e.printStackTrace();
+            throw new ServletException(e.getMessage());
+        } finally {
+            IOUtils.closeQuietly(in);
+        }
     }
-    catch (FileNotFoundException e) {
-      e.printStackTrace();
-      throw new ServletException(e.getMessage());
-    } 
-    catch (ClassNotFoundException e) {
-      e.printStackTrace();
-      throw new ServletException(e.getMessage());
-    } 
-    catch (IllegalArgumentException e) {
-      e.printStackTrace();
-      throw new ServletException(e.getMessage());
-    } 
-    catch (IOException e) {
-      e.printStackTrace();
-      throw new ServletException(e.getMessage());
-    } 
-    catch (Throwable e) {
-      e.printStackTrace();
-      throw new ServletException(e.getMessage());
-    }
-  }
 
 
   /**
Index: src/edu/ucsb/nceas/metacat/oaipmh/provider/server/crosswalk/Eml2oai_dc.java
===================================================================
--- src/edu/ucsb/nceas/metacat/oaipmh/provider/server/crosswalk/Eml2oai_dc.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/oaipmh/provider/server/crosswalk/Eml2oai_dc.java	(revision 8304)
@@ -21,6 +21,8 @@
 import javax.xml.transform.stream.StreamResult;
 import javax.xml.transform.stream.StreamSource;
 
+import org.apache.commons.io.IOUtils;
+
 import ORG.oclc.oai.server.crosswalk.Crosswalk;
 import ORG.oclc.oai.server.verb.CannotDisseminateFormatException;
 import ORG.oclc.oai.server.verb.OAIInternalServerError;
@@ -69,27 +71,37 @@
     String xsltPath200 = dirPath + "/" + XSLT_NAME_200;
     String xsltPath201 = dirPath + "/" + XSLT_NAME_201;
     String xsltPath210 = dirPath + "/" + XSLT_NAME_210;
+    FileInputStream fileInputStream200 = null;
+    FileInputStream fileInputStream201 = null;
+    FileInputStream fileInputStream210 = null;
     
     try {
       TransformerFactory tFactory200 = TransformerFactory.newInstance();
-      FileInputStream fileInputStream200 = new FileInputStream(xsltPath200);
+      fileInputStream200 = new FileInputStream(xsltPath200);
       StreamSource xslSource200 = new StreamSource(fileInputStream200);
       this.transformer200 = tFactory200.newTransformer(xslSource200);
-
+      fileInputStream200.close();
+      
       TransformerFactory tFactory201 = TransformerFactory.newInstance();
-      FileInputStream fileInputStream201 = new FileInputStream(xsltPath201);
+      fileInputStream201 = new FileInputStream(xsltPath201);
       StreamSource xslSource201 = new StreamSource(fileInputStream201);
       this.transformer201 = tFactory201.newTransformer(xslSource201);
-
+      fileInputStream201.close();
+      
       TransformerFactory tFactory210 = TransformerFactory.newInstance();
-      FileInputStream fileInputStream210 = new FileInputStream(xsltPath210);
+      fileInputStream210 = new FileInputStream(xsltPath210);
       StreamSource xslSource210 = new StreamSource(fileInputStream210);
       this.transformer210 = tFactory210.newTransformer(xslSource210);
+      fileInputStream210.close();
 
     } 
     catch (Exception e) {
       e.printStackTrace();
       throw new OAIInternalServerError(e.getMessage());
+    } finally {
+        IOUtils.closeQuietly(fileInputStream200);
+        IOUtils.closeQuietly(fileInputStream201);
+        IOUtils.closeQuietly(fileInputStream210);
     }
   }
   
Index: src/edu/ucsb/nceas/metacat/admin/DBAdmin.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/DBAdmin.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/admin/DBAdmin.java	(revision 8304)
@@ -65,6 +65,7 @@
 import edu.ucsb.nceas.utilities.GeneralPropertyException;
 import edu.ucsb.nceas.utilities.PropertyNotFoundException;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 
 /**
@@ -976,9 +977,9 @@
 					} while ((fileLine = reader.readLine()) != null);
 				}
 			}
+			fin.close();
 		} finally {
-			// Close our input stream
-			fin.close();
+			IOUtils.closeQuietly(fin);
 		}
 
 		return sqlCommands;
Index: src/edu/ucsb/nceas/metacat/replication/ReplicationService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/replication/ReplicationService.java	(revision 8303)
+++ src/edu/ucsb/nceas/metacat/replication/ReplicationService.java	(revision 8304)
@@ -1258,13 +1258,14 @@
 			// close file input stream
 			fin.close();
 
-		}//try
-		catch (Exception e) {
+		} catch (Exception e) {
 			logMetacat.error("ReplicationService.handleGetDataFileRequest - " + ReplicationService.METACAT_REPL_ERROR_MSG);                         
 			logReplication.error("ReplicationService.handleGetDataFileRequest - error getting data file from MetacatReplication."
 					+ "handlGetDataFileRequest " + e.getMessage());
 			e.printStackTrace(System.out);
-		}//catch
+		} finally {
+		    IOUtils.closeQuietly(fin);
+		}
 
 	}
 
