Repository: tomee Updated Branches: refs/heads/master a47eb2575 -> a6a136c3c
nopmd for windows System.gc() call Project: http://git-wip-us.apache.org/repos/asf/tomee/repo Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/a6a136c3 Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/a6a136c3 Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/a6a136c3 Branch: refs/heads/master Commit: a6a136c3c5fc44dace261087e518aeed896bd3c4 Parents: a47eb25 Author: Romain Manni-Bucau <[email protected]> Authored: Tue Mar 24 11:26:54 2015 +0100 Committer: Romain Manni-Bucau <[email protected]> Committed: Tue Mar 24 11:26:54 2015 +0100 ---------------------------------------------------------------------- .../java/org/apache/openejb/loader/Files.java | 39 +++++++------------- 1 file changed, 14 insertions(+), 25 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tomee/blob/a6a136c3/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java ---------------------------------------------------------------------- diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java index b131a49..a8bbb7e 100644 --- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java +++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/Files.java @@ -44,7 +44,7 @@ import static org.apache.openejb.loader.JarLocation.decode; */ public class Files { private static final Map<String, MessageDigest> DIGESTS = new HashMap<String, MessageDigest>(); - private static final boolean isWindows = System.getProperty("os.name", "unknown").toLowerCase().startsWith("win"); + private static final boolean IS_WINDOWS = System.getProperty("os.name", "unknown").toLowerCase().startsWith("win"); public static File path(final String... parts) { File dir = null; @@ -170,10 +170,7 @@ public class Files { return file; } - if (isWindows) { - //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS - System.gc(); - } + hackJDK4715154(); if (!file.mkdirs()) { throw new FileRuntimeException("Cannot mkdir: " + file.getAbsolutePath()); @@ -181,6 +178,13 @@ public class Files { return file; } + private static void hackJDK4715154() { + if (IS_WINDOWS) { //NOPMD + //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS + System.gc(); + } + } + public static File mkdir(final File file, final String name) { return mkdir(new File(file, name)); } @@ -194,10 +198,7 @@ public class Files { //Use a local tmp directory final File tmp = new File("tmp"); - if (isWindows) { - //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS - System.gc(); - } + hackJDK4715154(); if (!tmp.exists() && !tmp.mkdirs()) { throw new IOException("Failed to create local tmp directory: " + tmp.getAbsolutePath()); @@ -206,10 +207,7 @@ public class Files { file = File.createTempFile("temp", "dir", tmp); } - if (isWindows) { - //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS - System.gc(); - } + hackJDK4715154(); if (!file.delete()) { throw new IOException("Failed to create temp dir. Delete failed"); @@ -234,10 +232,7 @@ public class Files { if (!file.exists()) { - if (isWindows) { - //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS - System.gc(); - } + hackJDK4715154(); if (!file.mkdirs()) { throw new FileRuntimeException("Cannot mkdirs: " + file.getAbsolutePath()); @@ -317,10 +312,7 @@ public class Files { } try { - if (isWindows) { - //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS - System.gc(); - } + hackJDK4715154(); if (!file.delete()) { file.deleteOnExit(); @@ -350,10 +342,7 @@ public class Files { } } - if (isWindows) { - //Known Windows bug JDK-4715154 and as of JDK8 still not fixable due to OS - System.gc(); - } + hackJDK4715154(); if (!file.delete()) { throw new IllegalStateException("Could not delete file: " + file.getAbsolutePath());
