You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mark Hindess (JIRA)" <ji...@apache.org> on 2007/01/12 20:30:28 UTC
[jira] Resolved: (HARMONY-2031) [classlib][swing] JEditorPane
setContentType(String), setPage(String) and setPage(URL) throw wrong
exceptions if parameter is null
[ https://issues.apache.org/jira/browse/HARMONY-2031?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Mark Hindess resolved HARMONY-2031.
-----------------------------------
Resolution: Fixed
Assignee: Mark Hindess
Thanks for the fix. Applied the patches in r495692. Please confirm that they have been applied as expected.
> [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.<init>(Reader.java:54)
> at java.io.StringReader.<init>(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