Author: epbernard
Date: 2008-03-05 15:21:13 -0500 (Wed, 05 Mar 2008)
New Revision: 14391
Modified:
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitorFactory.java
Log:
EJB-333 space problem in container
Modified:
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java
===================================================================
---
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java 2008-03-04
22:42:53 UTC (rev 14390)
+++
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/ExplodedJarVisitor.java 2008-03-05
20:21:13 UTC (rev 14391)
@@ -36,12 +36,20 @@
protected void doProcessElements() throws IOException {
File jarFile;
try {
- jarFile = new File( jarUrl.toURI().getSchemeSpecificPart() );
+ String filePart = jarUrl.getFile();
+ if ( filePart != null && filePart.indexOf( ' ' ) != -1 ) {
+ //unescaped (from the container), keep as is
+ jarFile = new File( jarUrl.getFile() );
+ }
+ else {
+ jarFile = new File( jarUrl.toURI().getSchemeSpecificPart() );
+ }
}
catch (URISyntaxException e) {
log.warn( "Malformed url: " + jarUrl, e );
return;
}
+
if ( !jarFile.exists() ) {
log.warn( "Exploded jar does not exists (ignored): " + jarUrl );
return;
Modified:
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java
===================================================================
---
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java 2008-03-04
22:42:53 UTC (rev 14390)
+++
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/FileZippedJarVisitor.java 2008-03-05
20:21:13 UTC (rev 14391)
@@ -5,6 +5,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.net.URL;
import java.net.URISyntaxException;
import java.util.Enumeration;
@@ -36,7 +37,14 @@
protected void doProcessElements() throws IOException {
JarFile jarFile;
try {
- jarFile = new JarFile( jarUrl.toURI().getSchemeSpecificPart() );
+ String filePart = jarUrl.getFile();
+ if ( filePart != null && filePart.indexOf( ' ' ) != -1 ) {
+ //unescaped (from the container), keep as is
+ jarFile = new JarFile( jarUrl.getFile() );
+ }
+ else {
+ jarFile = new JarFile( jarUrl.toURI().getSchemeSpecificPart() );
+ }
}
catch (IOException ze) {
log.warn( "Unable to find file (ignored): " + jarUrl, ze );
@@ -46,6 +54,7 @@
log.warn( "Malformed url: " + jarUrl, e );
return;
}
+
if ( entry != null && entry.length() == 1 ) entry = null; //no entry
if ( entry != null && entry.startsWith( "/" ) ) entry =
entry.substring( 1 ); //remove '/' header
Modified: entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitorFactory.java
===================================================================
---
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitorFactory.java 2008-03-04
22:42:53 UTC (rev 14390)
+++
entitymanager/trunk/src/java/org/hibernate/ejb/packaging/JarVisitorFactory.java 2008-03-05
20:21:13 UTC (rev 14391)
@@ -1,12 +1,12 @@
//$
package org.hibernate.ejb.packaging;
-import java.net.URL;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
-import java.io.File;
-import java.io.InputStream;
-import java.io.IOException;
+import java.net.URL;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -50,7 +50,8 @@
}
else if ( "zip".equals( protocol ) //Weblogic has it's own way
|| "code-source".equals( url.getProtocol() ) //OC4J prevent ejb.jar access
(ie everything without path)
- || "file".equals( protocol ) ) { //if no wrapping is done
+ || "file".equals( protocol ) //if no wrapping is done
+ ) {
//we have extracted the zip file, so it should be read as a file
if ( file.indexOf( ' ' ) != -1 ) {
//not escaped, need to voodoo
@@ -107,13 +108,21 @@
else if ( StringHelper.isEmpty( protocol ) || "file".equals( protocol ) ) {
File file;
try {
- file = new File( jarUrl.toURI().getSchemeSpecificPart() );
+ final String filePart = jarUrl.getFile();
+ if ( filePart != null && filePart.indexOf( ' ' ) != -1 ) {
+ //unescaped (from the container), keep as is
+ file = new File( jarUrl.getFile() );
+ }
+ else {
+ file = new File( jarUrl.toURI().getSchemeSpecificPart() );
+ }
}
catch (URISyntaxException e) {
throw new IllegalArgumentException(
"Unable to visit JAR " + jarUrl + ". Cause: " + e.getMessage(),
e
);
}
+
if ( file.isDirectory() ) {
return new ExplodedJarVisitor( jarUrl, filters, entry );
}
Show replies by date