[Arakhnę-Dev] [158] Another bug fix: FileSystem URL string to URL convertion.

[ Thread Index | Date Index | More arakhne.org/dev Archives ]


Revision: 158
Author:   galland
Date:     2010-06-15 10:11:52 +0200 (Tue, 15 Jun 2010)
Log Message:
-----------
Another bug fix: FileSystem URL string to URL convertion.

Modified Paths:
--------------
    trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
    trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java

Modified: trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java
===================================================================
--- trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2010-06-15 07:27:23 UTC (rev 157)
+++ trunk/arakhneVmutils/java/src/main/java/org/arakhne/vmutil/FileSystem.java	2010-06-15 08:11:52 UTC (rev 158)
@@ -1236,7 +1236,13 @@
 
 		if (urlDescription!=null && urlDescription.length()>0)  {
 
-			if (URISchemeType.FILE.isScheme(urlDescription)) {
+			if (URISchemeType.RESOURCE.isScheme(urlDescription)) {
+				if (allowResourceSearch) {
+					String resourceName = urlDescription.substring(9);
+					url = Resources.getResource(resourceName);
+				}
+			}
+			else if (URISchemeType.FILE.isScheme(urlDescription)) {
 				File file = new File(URISchemeType.FILE.removeScheme(urlDescription));
 				try {
 					url = new URL(URISchemeType.FILE.name(), "", file.getPath()); //$NON-NLS-1$
@@ -1256,20 +1262,10 @@
 			
 			if (url==null) {
 				if (allowResourceSearch) {
-					
-					String resourceName;
-					
-					if (URISchemeType.RESOURCE.isScheme(urlDescription)) {
-						resourceName = urlDescription.substring(9);
-						url = Resources.getResource(resourceName);
-					}
-					
-					if (url==null) {
-						resourceName = urlDescription;
-						url = Resources.getResource(resourceName);
-					}
+					url = Resources.getResource(urlDescription);
 				}
-				else if (urlDescription.toLowerCase().startsWith(URISchemeType.RESOURCE.toString())) {
+				
+				if (url==null && URISchemeType.RESOURCE.isScheme(urlDescription)) {
 					return null;
 				}
 		

Modified: trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java
===================================================================
--- trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java	2010-06-15 07:27:23 UTC (rev 157)
+++ trunk/arakhneVmutils/java/src/test/java/org/arakhne/vmutil/FileSystemTest.java	2010-06-15 08:11:52 UTC (rev 158)
@@ -94,6 +94,7 @@
 	@Override
 	public void setUp() throws Exception {
 		super.setUp();
+		FileResourceURLStreamHandlerFactoryStub.SINGLETON.disable();
 		// Disable native library loading during unit tests
 		this.oldLibraryLoaderState = LibraryLoader.isEnable();
 		LibraryLoader.setEnable(false);
@@ -105,6 +106,7 @@
 	@Override
 	public void tearDown() throws Exception {
 		// Restore library loading state
+		FileResourceURLStreamHandlerFactoryStub.SINGLETON.disable();
 		LibraryLoader.setEnable(this.oldLibraryLoaderState);
 		super.tearDown();
 	}


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/