[kaffe] CVS kaffe (guilhem): RMI quick fix: check if getFile() begins with a '/' and removes it if necessary.

Kaffe CVS cvs-commits at kaffe.org
Wed Aug 20 01:32:02 PDT 2003


PatchSet 3964 
Date: 2003/08/20 08:29:26
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
RMI quick fix: check if getFile() begins with a '/' and removes it if necessary.

Members: 
	ChangeLog:1.1562->1.1563 
	libraries/javalib/java/rmi/Naming.java:1.2->1.3 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1562 kaffe/ChangeLog:1.1563
--- kaffe/ChangeLog:1.1562	Wed Aug 20 06:19:15 2003
+++ kaffe/ChangeLog	Wed Aug 20 08:29:26 2003
@@ -1,5 +1,12 @@
 2003-08-20  Guilhem Lavaux <guilhem at kaffe.org>
 
+	* libraries/javalib/java/rmi/Naming.java:
+	(lookup,bind,rebind) check if the first character of the filename
+	returned by URL.getFile() is a '/', only if it is the case we cut
+	this first character and call the registry with the good name.
+
+2003-08-20  Guilhem Lavaux <guilhem at kaffe.org>
+
 	* libraries/javalib/java/io/ObjectInputStream.java:
 	(readClassDescriptor) call resolveClass(ObjectStreamClass)
 	at the right moment ant not resolveClass(String) at the top of
Index: kaffe/libraries/javalib/java/rmi/Naming.java
diff -u kaffe/libraries/javalib/java/rmi/Naming.java:1.2 kaffe/libraries/javalib/java/rmi/Naming.java:1.3
--- kaffe/libraries/javalib/java/rmi/Naming.java:1.2	Mon Aug 18 17:40:34 2003
+++ kaffe/libraries/javalib/java/rmi/Naming.java	Wed Aug 20 08:29:27 2003
@@ -62,7 +62,14 @@
 	// hack to accept "rmi://host:port/service" strings
 	if(name.startsWith("rmi:")){ name = name.substring(4); }
 	URL u = new URL("http:" + name);
-	return (getRegistry(u).lookup(u.getFile().substring(1)));
+	String filename = u.getFile();
+
+	// If the filename begins with a slash we must cut it for
+	// name resolution.
+	if (filename.charAt(0) == '/')
+		return (getRegistry(u).lookup(filename.substring(1)));
+	else
+		return (getRegistry(u).lookup(filename));
 }
 
 /**
@@ -75,7 +82,13 @@
  */
 public static void bind(String name, Remote obj) throws AlreadyBoundException, MalformedURLException, RemoteException {
 	URL u = new URL("http:" + name);
-	getRegistry(u).bind(u.getFile().substring(1), obj);
+	String filename = u.getFile();
+	// If the filename begins with a slash we must cut it for
+	// name resolution.
+	if (filename.charAt(0) == '/')
+		getRegistry(u).bind(filename.substring(1), obj);
+	else
+		getRegistry(u).bind(filename, obj);
 }
 
 /**
@@ -87,7 +100,13 @@
  */
 public static void unbind(String name) throws RemoteException, NotBoundException, MalformedURLException {
 	URL u = new URL("http:" + name);
-	getRegistry(u).unbind(u.getFile().substring(1));
+	String filename = u.getFile();
+	// If the filename begins with a slash we must cut it for
+	// name resolution.
+	if (filename.charAt(0) == '/')
+		getRegistry(u).unbind(filename.substring(1));
+	else
+		getRegistry(u).unbind(filename);
 }
 
 /**
@@ -100,7 +119,13 @@
  */
 public static void rebind(String name, Remote obj) throws RemoteException, MalformedURLException {
 	URL u = new URL("http:" + name);
-	getRegistry(u).rebind(u.getFile().substring(1), obj);
+	String filename = u.getFile();
+	// If the filename begins with a slash we must cut it for
+	// name resolution.
+	if (filename.charAt(0) == '/')
+		getRegistry(u).rebind(filename.substring(1), obj);
+	else
+		getRegistry(u).rebind(filename, obj);
 }
 
 /**




More information about the kaffe mailing list