JarFile/ZipFile does not implement closeable in java 6

This commit is contained in:
Sebastian Sdorra
2012-10-30 09:35:12 +01:00
parent a2703800e3
commit 1c13ca27f8
2 changed files with 51 additions and 5 deletions

View File

@@ -127,10 +127,7 @@ public abstract class AbstractBaseScmMojo extends AbstractScmMojo
}
finally
{
if (scanner != null)
{
scanner.close();
}
Util.close(scanner);
}
}
catch (IOException ex)
@@ -140,7 +137,7 @@ public abstract class AbstractBaseScmMojo extends AbstractScmMojo
finally
{
IOUtils.closeQuietly(input);
IOUtils.closeQuietly(file);
Util.close(getLog(), file);
}
return excludeList;

View File

@@ -33,6 +33,17 @@
package sonia.scm.maven;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.maven.plugin.logging.Log;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Scanner;
import java.util.zip.ZipFile;
/**
*
* @author Sebastian Sdorra
@@ -40,6 +51,44 @@ package sonia.scm.maven;
public class Util
{
/**
* Method description
*
*
* @param log
* @param file
*/
public static void close(Log log, ZipFile file)
{
if (file != null)
{
try
{
file.close();
}
catch (IOException ex)
{
log.warn("could not close zipfile", ex);
}
}
}
/**
* Method description
*
*
* @param scanner
*/
public static void close(Scanner scanner)
{
if (scanner != null)
{
scanner.close();
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*