You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by te...@apache.org on 2007/02/05 14:14:00 UTC

svn commit: r503668 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/net/ test/java/org/apache/harmony/tests/java/net/ test/java/org/apache/harmony/tests/java/net/test_protocol/

Author: tellison
Date: Mon Feb  5 05:13:59 2007
New Revision: 503668

URL: http://svn.apache.org/viewvc?view=rev&rev=503668
Log:
Apply patch HARMONY-3094 ([classlib][luni] java.net.URL.setupStreamHandler() works incorrectly if set System property "java.protocol.handler.pkgs")

Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/Handler.java   (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java?view=diff&rev=503668&r1=503667&r2=503668
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/net/URL.java Mon Feb  5 05:13:59 2007
@@ -595,15 +595,14 @@
                     strmHandler = (URLStreamHandler) Class.forName(className,
                             true, ClassLoader.getSystemClassLoader())
                             .newInstance();
+                    if (strmHandler != null) {
+                        streamHandlers.put(protocol, strmHandler);
+                    }
+                    return;
                 } catch (IllegalAccessException e) {
                 } catch (InstantiationException e) {
                 } catch (ClassNotFoundException e) {
                 }
-                if (strmHandler != null) {
-                    streamHandlers.put(protocol, strmHandler);
-                }
-                return;
-
             }
         }
 

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLTest.java?view=diff&rev=503668&r1=503667&r2=503668
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLTest.java Mon Feb  5 05:13:59 2007
@@ -61,4 +61,25 @@
 		assertEquals("Assert 3: wrong file", "test.html", testURL.getFile());
 		assertEquals("Assert 4: wrong anchor", "anch", testURL.getRef());
 	}
+
+	/**
+	 * @tests java.net.URL#URL(String, String, String)
+	 *
+	 */
+	public void test_java_protocol_handler_pkgs_prop() throws MalformedURLException {
+		// Regression test for Harmony-3094
+        final String HANDLER_PKGS = "java.protocol.handler.pkgs";
+		String pkgs = System.getProperty(HANDLER_PKGS);
+		System.setProperty(HANDLER_PKGS, "fake|org.apache.harmony.tests.java.net");
+
+		try {
+			new URL("test_protocol", "", "fake.jar");
+		} finally {
+			if (pkgs == null) {
+				System.clearProperty(HANDLER_PKGS);
+			} else {
+				System.setProperty(HANDLER_PKGS, pkgs);
+			}
+		}
+	}
 }

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/Handler.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/Handler.java?view=auto&rev=503668
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/Handler.java (added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/Handler.java Mon Feb  5 05:13:59 2007
@@ -0,0 +1,30 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.net.test_protocol;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+public class Handler extends URLStreamHandler {
+    protected URLConnection openConnection(URL u) throws IOException {
+        return null;
+    }
+}
+

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/test_protocol/Handler.java
------------------------------------------------------------------------------
    svn:eol-style = native