Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 4972 invoked from network); 15 Jan 2007 20:22:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Jan 2007 20:22:49 -0000 Received: (qmail 80751 invoked by uid 500); 15 Jan 2007 20:22:55 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 80710 invoked by uid 500); 15 Jan 2007 20:22:55 -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 80690 invoked by uid 99); 15 Jan 2007 20:22:55 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jan 2007 12:22:55 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= 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; Mon, 15 Jan 2007 12:22:48 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id E7C447142B6 for ; Mon, 15 Jan 2007 12:22:27 -0800 (PST) Message-ID: <6240755.1168892547947.JavaMail.jira@brutus> Date: Mon, 15 Jan 2007 12:22:27 -0800 (PST) From: "Mark Hindess (JIRA)" To: commits@harmony.apache.org Subject: [jira] Closed: (HARMONY-2031) [classlib][swing] JEditorPane setContentType(String), setPage(String) and setPage(URL) throw wrong exceptions if parameter is null 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-2031?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Mark Hindess closed HARMONY-2031. --------------------------------- Verified. Thanks. > [classlib][swing] JEditorPane setContentType(String), setPage(String) and setPage(URL) throw wrong exceptions if parameter is null > ---------------------------------------------------------------------------------------------------------------------------------- > > Key: HARMONY-2031 > URL: https://issues.apache.org/jira/browse/HARMONY-2031 > Project: Harmony > Issue Type: Bug > Components: Classlib > Reporter: Denis Kishenko > Assigned To: Mark Hindess > Attachments: Harmony-2031-JEditorPane.patch, Harmony-2031-JEditorPaneTest.patch > > > JEditorPane methods setContentType(String), setPage(String) and setPage(URL) > doesn't throw specified exceptions for null parameters. And method > setText(String) illegally throws NPE for null parameter. The behavior of these > methods contrary to J2SE 1.5 specification and RI behavior. > 1. Method setContentType(String) should throw NPE for null parameter according > to specification: > public final void setContentType(String type) > Sets the type of content that this editor handles. This calls > getEditorKitForContentType, and then setEditorKit if an editor kit can be > successfully located. This is mostly convenience method that can be used as an > alternative to calling setEditorKit directly. If there is a charset definition > specified as a parameter of the content type specification, it will be used > when loading input streams using the associated EditorKit. For example if the > type is specified as text/html; charset=EUC-JP the content will be loaded using > the EditorKit registered for text/html and the Reader provided to the EditorKit > to load unicode into the document will use the EUC-JP charset for translating > to unicode. If the type is not recognized, the content will be loaded using the > EditorKit registered for plain text, text/plain. > Parameters: type - the non-null mime type for the content editing support > Throws: NullPointerException - if the type parameter is null > This method doesn't throw NPE for setContentType(null). Meanwhile, RI of this > method throws NPE. > 2. According to specification: > public void setPage(URL page) throws IOException > Sets the current URL being displayed. The content type of the pane is set, and > if the editor kit for the pane is non-null, then a new default document is > created and the URL is read into it. If the URL contains and reference > location, the location will be scrolled to by calling the scrollToReference > method. If the desired URL is the one currently being displayed, the document > will not be reloaded. To force a document reload it is necessary to clear the > stream description property of the document. > Parameters: page - the URL of the page > Throws: IOException - for a null or invalid page specification, or exception > from the stream being read > method setPage(URL) should throw IOE for null parameter, but this methods > doesn't. > RI of this method throws NPE for null parameter. > 3. Method setText(String) throws unspecified NPE for null parameter. The > behavior of this method contrary to specification: > public void setText(String t) > Sets the text of this TextComponent to the specified content, which is expected > to be in the format of the content type of this editor. For example, if the > type is set to text/html the string should be specified in terms of HTML. > Overrides: setText in class JTextComponent > Parameters: t - the new text to be set; if null the old text will be deleted > and RI behavior. > ========= Test =========== > import java.io.IOException; > import java.net.URL; > import javax.swing.JEditorPane; > import junit.framework.TestCase; > public class Test extends TestCase { > > public void testSetContentType() { > JEditorPane e = new JEditorPane(); > boolean b = false; > try { > e.setContentType((String)null); > } catch (NullPointerException npe) { > npe.printStackTrace(); > b = true; > } catch (Throwable t) { > t.printStackTrace(); > } > assertTrue(b); > } > > public void testSetPage() { > JEditorPane e = new JEditorPane(); > boolean b = false; > try { > e.setPage((URL)null); > } catch (IOException ioe) { > ioe.printStackTrace(); > b = true; > } catch (Throwable t) { > t.printStackTrace(); > } > assertTrue(b); > } > public void testSetText() { > JEditorPane e = new JEditorPane(); > boolean b = true; > try { > e.setText((String)null); > } catch (Throwable t) { > t.printStackTrace(); > b = false; > } > assertTrue(b); > } > } > =========== RI ============ > java.io.IOException: invalid url > at javax.swing.JEditorPane.setPage(JEditorPane.java:393) > at bug7610.testSetPage(bug7610.java:29) > at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) > at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source) > at junit.framework.TestCase.runTest(TestCase.java:164) > at junit.framework.TestCase.runBare(TestCase.java:130) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:120) > at junit.framework.TestSuite.runTest(TestSuite.java:230) > at junit.framework.TestSuite.run(TestSuite.java:225) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) > java.lang.NullPointerException > at javax.swing.JEditorPane.setContentType(JEditorPane.java:873) > at bug7610.testSetContentType(bug7610.java:15) > at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source) > at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source) > at junit.framework.TestCase.runTest(TestCase.java:164) > at junit.framework.TestCase.runBare(TestCase.java:130) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:120) > at junit.framework.TestSuite.runTest(TestSuite.java:230) > at junit.framework.TestSuite.run(TestSuite.java:225) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) > =========== Harmony ======= > java.lang.NullPointerException > at java.io.Reader.(Reader.java:54) > at java.io.StringReader.(StringReader.java:42) > at javax.swing.JEditorPane.setText(JEditorPane.java:738) > at bug7610.testSetText(bug7610.java:43) > at java.lang.reflect.VMReflection.invokeMethod() > at java.lang.reflect.Method.invoke() > at junit.framework.TestCase.runTest(TestCase.java:164) > at junit.framework.TestCase.runBare(TestCase.java:130) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:120) > at junit.framework.TestSuite.runTest(TestSuite.java:230) > at junit.framework.TestSuite.run(TestSuite.java:225) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478) > at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira