Author: andygumbrecht
Date: Tue Apr 10 14:00:24 2012
New Revision: 1311727
URL: http://svn.apache.org/viewvc?rev=1311727&view=rev
Log:
Set default antiJarLocking to false. I have had this disabled on Win platforms
for a long time with no ill effects.
Fix temp directory creation - Broken in 1245047 by creating a file rather than
directory. I had disabled antiJarLocking on my system, so only noticed during a
full rebuild.
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
Modified:
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java?rev=1311727&r1=1311726&r2=1311727&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/util/UrlCache.java
Tue Apr 10 14:00:24 2012
@@ -27,15 +27,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
+import java.util.*;
import java.util.jar.Attributes;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
@@ -46,25 +38,9 @@ public class UrlCache {
public static final boolean antiJarLocking;
public static final File cacheDir;
- static {
- String value = null;
- for (Map.Entry<Object, Object> entry :
System.getProperties().entrySet()) {
- if (entry.getKey() instanceof String && entry.getValue()
instanceof String) {
- if ("antiJarLocking".equalsIgnoreCase((String)
entry.getKey())) {
- value = (String) entry.getValue();
- break;
- }
- }
- }
-
- if (value != null) {
- antiJarLocking = Boolean.valueOf(value);
- } else {
- final boolean embedded =
SystemInstance.get().getOptions().get("openejb.embedded", false);
- // antiJarLocking is on by default when we are not embedded and
running on windows
- antiJarLocking = !embedded && System.getProperty("os.name",
"unknown").toLowerCase().startsWith("windows");
- }
-
+ static {
+ antiJarLocking =
SystemInstance.get().getOptions().get("antiJarLocking", false);
+
if (antiJarLocking) {
cacheDir = createCacheDir();
logger.info("AntiJarLocking enabled. Using URL cache dir " +
cacheDir);
@@ -72,6 +48,7 @@ public class UrlCache {
cacheDir = null;
}
}
+
private final Map<String, Map<URL, File>> cache = new TreeMap<String,
Map<URL, File>>();
public synchronized URL[] cacheUrls(String appId, URL[] urls) {
@@ -330,8 +307,8 @@ public class UrlCache {
}
// if we are embedded, tmp dir is in the system tmp dir
- if (dir == null) {
- dir = File.createTempFile("OpenEJB-temp-", "");
+ if (dir == null) {
+ dir = new File(new File(System.getProperty("java.io.tmpdir")),
UUID.randomUUID().toString());
}
// If the cache dir already exists then empty its contents
@@ -354,9 +331,20 @@ public class UrlCache {
}
private static File createCacheDir(File dir) throws IOException {
- if (!dir.mkdirs() && !dir.isDirectory()) {
+
+ if(dir.exists() && dir.isDirectory()){
+ return dir;
+ }
+
+ if (dir.exists() && !dir.isDirectory()) {
+ throw new IOException("Cache temp directory held by file: " + dir);
+ }
+
+ if (!dir.mkdirs()) {
throw new IOException("Unable to create cache temp directory: " +
dir);
}
+
+ Thread.yield();
return dir;
}
Modified:
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
URL:
http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java?rev=1311727&r1=1311726&r2=1311727&view=diff
==============================================================================
---
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
(original)
+++
openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/assembler/classic/RedeployTest.java
Tue Apr 10 14:00:24 2012
@@ -29,6 +29,7 @@ import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.File;
+import java.lang.Exception;
import java.util.Properties;
/**
@@ -38,6 +39,9 @@ public class RedeployTest extends TestCa
public void test() throws Exception {
// create reference to openejb itests
File file = JarLocation.jarLocation(BasicStatelessBean.class);
+ if(!file.exists()){
+ throw new Exception("File not found: " + file);
+ }
// These two objects pretty much encompas all the EJB Container
ConfigurationFactory config = new ConfigurationFactory();