Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 36924 invoked from network); 8 Feb 2008 17:12:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Feb 2008 17:12:32 -0000 Received: (qmail 55559 invoked by uid 500); 8 Feb 2008 17:12:25 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 55532 invoked by uid 500); 8 Feb 2008 17:12:25 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 55523 invoked by uid 99); 8 Feb 2008 17:12:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 09:12:25 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2008 17:12:16 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 88908714074 for ; Fri, 8 Feb 2008 09:12:08 -0800 (PST) Message-ID: <17725638.1202490728555.JavaMail.jira@brutus> Date: Fri, 8 Feb 2008 09:12:08 -0800 (PST) From: "Vasily Zakharov (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-5477) [classlib][beans][geronimo] PropertyEditorManager.findEditor() used wrong classloader In-Reply-To: <33078910.1202490487666.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-5477?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12567098#action_12567098 ] Vasily Zakharov commented on HARMONY-5477: ------------------------------------------ PropertyEditorManager.findEditor() always uses the target class loader to locate the editor, while it should use thread context class loader when a particular editor is not found the the target class loader. Here's the test demonstrating the problem: {code:java} import java.beans.*; import java.net.*; public class Test { public static void main(String[] args) { try { PropertyEditorManager.setEditorSearchPath(new String[] { "myPackage" }); ClassLoader editorLoader = new URLClassLoader(new URL[] { new URL("file:./editor/") }); Thread.currentThread().setContextClassLoader(editorLoader); PropertyEditor editor = PropertyEditorManager.findEditor(MyClass.class); if (editor == null) { System.out.println("FAIL: null"); } else { String editorName = editor.getClass().getName(); System.out.println(editorName.equals("myPackage.MyClassEditor") ? "SUCCESS" : ("FAIL: " + editorName)); } } catch (Throwable e) { System.out.print("ERROR: "); e.printStackTrace(System.out); } } } class MyClass { } {code} {code:java} package myPackage; public class MyClassEditor extends java.beans.PropertyEditorSupport { } {code} Compiled {{MyClassEditor.class}} should be put to {{./editor/myPackage/MyClassEditor.class}} for the test to work. Output on RI: {code}SUCCESS{code} Output on Harmony: {code}FAIL: null{code} The reason the test fails is the editor is available in other classloader than the original class. That classloader is preliminarily specified by {{Thread.currentThread().setContextClassLoader()}}, but Harmony implementation doesn't use it. To fix, the classloader handling mechanism in {{PropertyEditorManager.findEditor()}} needs to be changed. This testcase was derived from {{org.apache.geronimo.common.propertyeditor.PropertyEditors.findEditor(String, ClassLoader)}} method. This issue prevents Geronimo 2.1-snapshot from starting on Harmony. > [classlib][beans][geronimo] PropertyEditorManager.findEditor() used wrong classloader > ------------------------------------------------------------------------------------- > > Key: HARMONY-5477 > URL: https://issues.apache.org/jira/browse/HARMONY-5477 > Project: Harmony > Issue Type: Bug > Components: App-Oriented Bug Reports, Classlib > Affects Versions: 5.0M5 > Reporter: Vasily Zakharov > Assignee: Vasily Zakharov > > PropertyEditorManager.findEditor() always uses the target class loader to locate the editor, while it should use thread context class loader when a particular editor is not found the the target class loader. > Here's the test demonstrating the problem: > {code:java} > import java.beans.*; > import java.net.*; > public class Test { > public static void main(String[] args) { > try { > PropertyEditorManager.setEditorSearchPath(new String[] { "myPackage" }); > ClassLoader editorLoader = new URLClassLoader(new URL[] { new URL("file:./editor/") }); > Thread.currentThread().setContextClassLoader(editorLoader); > PropertyEditor editor = PropertyEditorManager.findEditor(MyClass.class); > if (editor == null) { > System.out.println("FAIL: null"); > } else { > String editorName = editor.getClass().getName(); > System.out.println(editorName.equals("myPackage.MyClassEditor") ? "SUCCESS" : ("FAIL: " + editorName)); > } > } catch (Throwable e) { > System.out.print("ERROR: "); > e.printStackTrace(System.out); > } > } > } > class MyClass { > } > {code} > {code:java} > package myPackage; > public class MyClassEditor extends java.beans.PropertyEditorSupport { > } > {code} > Compiled {{MyClassEditor.class}} should be put to {{./editor/myPackage/MyClassEditor.class}} for the test to work. > Output on RI: > {code}SUCCESS{code} > Output on Harmony: > {code}FAIL: null{code} > The reason the test fails is the editor is available in other classloader than the original class. That classloader is preliminarily specified by {{Thread.currentThread().setContextClassLoader()}}, but Harmony implementation doesn't use it. To fix, the classloader handling mechanism in {{PropertyEditorManager.findEditor()}} needs to be changed. > This testcase was derived from {{org.apache.geronimo.common.propertyeditor.PropertyEditors.findEditor(String, ClassLoader)}} method. > This issue prevents Geronimo 2.1-snapshot from starting on Harmony. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.