[hibernate-commits] Hibernate SVN: r11270 - in branches/Branch_3_2/HibernateExt/entitymanager/src: test and 1 other directory.

hibernate-commits at lists.jboss.org hibernate-commits at lists.jboss.org
Fri Mar 9 19:03:27 EST 2007


Author: epbernard
Date: 2007-03-09 19:03:27 -0500 (Fri, 09 Mar 2007)
New Revision: 11270

Modified:
   branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/JarVisitor.java
   branches/Branch_3_2/HibernateExt/entitymanager/src/test/log4j.properties
Log:
EJB-275 WAS does not encode URL, fantastic!

Modified: branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/JarVisitor.java
===================================================================
--- branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/JarVisitor.java	2007-03-09 21:00:58 UTC (rev 11269)
+++ branches/Branch_3_2/HibernateExt/entitymanager/src/java/org/hibernate/ejb/packaging/JarVisitor.java	2007-03-10 00:03:27 UTC (rev 11270)
@@ -57,17 +57,28 @@
 
 			if ( "jar".equals( protocol )
 					|| "wsjar".equals( protocol ) ) { //Websphere has it's own way
+				//Original URL is like jar:protocol
 				jarUrl = new URL( file );
+				if ( "file".equals( jarUrl.getProtocol() ) ) {
+					//Do some voodoo magic because WAS doesn't think escaping URL is an interesting feature
+					if ( file.indexOf( ' ' ) != -1 ) {
+						//not escaped, need to voodoo
+						jarUrl = new File( jarUrl.getFile() ).toURI().toURL(); //goes by toURI to escape the path
+					}
+				} //otherwise left as is
 			}
-			else if ( "zip".equals( protocol ) ) { //Weblogic has it's own way
+			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)
 				//we have extracted the zip file, so it should be read as a file
-				jarUrl = new URL( "file", null, file );
+				//Just in case some containers are as stupid as WAS: luckily WAS is closed source so nobody will dupe the bug
+				if ( file.indexOf( ' ' ) != -1 ) {
+					//not escaped, need to voodoo
+					jarUrl = new File(file).toURI().toURL(); //goes by toURI to escape the path
+				}
+				else {
+					jarUrl = new File(file).toURL();
+				}
 			}
-			else if ("code-source".equals( url.getProtocol() ) ) {
-				//OC4J prevent ejb.jar access (ie everything without path
-				//fix contributed by the community
-				jarUrl = new File(file).toURL();
-			}
 			else {
 				jarUrl = new URL( protocol, url.getHost(), url.getPort(), file );
 			}
@@ -77,6 +88,7 @@
 					"Unable to determine JAR Url from " + url + ". Cause: " + e.getMessage()
 			);
 		}
+		log.trace("JAR URL from URL Entry: " + url + " >> " + jarUrl);
 		return jarUrl;
 	}
 

Modified: branches/Branch_3_2/HibernateExt/entitymanager/src/test/log4j.properties
===================================================================
--- branches/Branch_3_2/HibernateExt/entitymanager/src/test/log4j.properties	2007-03-09 21:00:58 UTC (rev 11269)
+++ branches/Branch_3_2/HibernateExt/entitymanager/src/test/log4j.properties	2007-03-10 00:03:27 UTC (rev 11270)
@@ -18,6 +18,7 @@
 #log4j.logger.org.hibernate=debug
 
 log4j.logger.org.hibernate.ejb=debug
+log4j.logger.org.hibernate.ejb.packaging=debug
 log4j.logger.org.hibernate.reflection=debug
 
 #log4j.logger.org.hibernate.engine.Cascades=debug




More information about the hibernate-commits mailing list