Revision: 7744
Author: victormote
Date: 2006-06-25 15:19:10 -0700 (Sun, 25 Jun 2006)
ViewCVS: http://svn.sourceforge.net/foray/?rev=7744&view=rev
Log Message:
-----------
Remove throwing of the Exception if the protocol is already registered, since we have no way of definitively establishing that fact.
Modified Paths:
--------------
trunk/foray/foray-common/src/java/org/foray/common/url/AbstractURLStreamHandler.java
trunk/foray/foray-common/src/java/org/foray/common/url/FOrayURLStreamHandlerFactory.java
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/AbstractURLStreamHandler.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/AbstractURLStreamHandler.java 2006-06-24 22:14:37 UTC (rev 7743)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/AbstractURLStreamHandler.java 2006-06-25 22:19:10 UTC (rev 7744)
@@ -29,7 +29,6 @@
package org.foray.common.url;
-import java.io.IOException;
import java.net.URLStreamHandler;
import java.util.StringTokenizer;
@@ -74,21 +73,15 @@
protocol);
if (registeredHandler != null) {
/* If already registed, that one is the one being used, and there
- * is no way to change it. */
+ * is no way to change it. If it has in fact not yet been used,
+ * then registering this now would make the new one used instead
+ * of the old one. However, until we have some indication that this
+ * would be the "right" thing to do, we will not. */
return;
}
/* Register the protocol with the Factory. */
- try {
- factory.registerProtocol(protocol, handler);
- } catch (IOException e) {
- /* This should never happen. We have already checked whether the
- * protocol is previously registered, and we know that neither the
- * protocol or handler are null. The only thing we could do is
- * pass the exception upstream, but there is nothing they can do
- * about it either. */
- return;
- }
+ factory.registerProtocol(protocol, handler);
}
/**
Modified: trunk/foray/foray-common/src/java/org/foray/common/url/FOrayURLStreamHandlerFactory.java
===================================================================
--- trunk/foray/foray-common/src/java/org/foray/common/url/FOrayURLStreamHandlerFactory.java 2006-06-24 22:14:37 UTC (rev 7743)
+++ trunk/foray/foray-common/src/java/org/foray/common/url/FOrayURLStreamHandlerFactory.java 2006-06-25 22:19:10 UTC (rev 7744)
@@ -30,7 +30,6 @@
package org.foray.common.url;
-import java.io.IOException;
import java.net.URL;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
@@ -77,11 +76,8 @@
* @param handler The {@link URLStreamHandler} instance which should be
* used for URLs whose protocol is <code>protocol</code>.
* The registration will fail silently if this parameter is null.
- * @throws IOException If <code>protocol</code> has already been
- * registered.
*/
- public void registerProtocol(String protocol, URLStreamHandler handler)
- throws IOException {
+ public void registerProtocol(String protocol, URLStreamHandler handler) {
if (protocol == null) {
throw new IllegalArgumentException("Cannot register a null "
+ "protocol.");
@@ -90,10 +86,11 @@
throw new IllegalArgumentException("Cannot register a null "
+ "URLStreamHandler.");
}
- if (this.protocols.containsKey(protocol)) {
- throw new IOException("Protocol \n" + protocol
- + "\" has already been registered.");
- }
+ /* This could be futile. If a protocol has already been registered here
+ * and used by a URL, placing a new one in our Map will be totally
+ * ineffective. It is tempting to throw an exception in such a case,
+ * but there is no definitive way to know whether the registration was
+ * successful or not, so we will not. */
this.protocols.put(protocol, handler);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|