Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 68714 invoked from network); 13 Jan 2007 17:29:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jan 2007 17:29:57 -0000 Received: (qmail 82790 invoked by uid 500); 13 Jan 2007 17:30:03 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 82760 invoked by uid 500); 13 Jan 2007 17:30:03 -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 82737 invoked by uid 99); 13 Jan 2007 17:30:03 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Jan 2007 09:30:03 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Jan 2007 09:29:56 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 43A741A981A; Sat, 13 Jan 2007 09:28:54 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r495930 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/text/StyledEditorKit.java test/api/java/common/javax/swing/text/StyledEditorKitTest.java Date: Sat, 13 Jan 2007 17:28:53 -0000 To: commits@harmony.apache.org From: hindessm@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070113172854.43A741A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: hindessm Date: Sat Jan 13 09:28:51 2007 New Revision: 495930 URL: http://svn.apache.org/viewvc?view=rev&rev=495930 Log: Applying patch from "[#HARMONY-2594] [classlib][swing] javax.swing.text.StyledEditorKit.createInputAttributes(Element element, MutableAttributeSet set) doesn't throw NPE when any of arguments is null". Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java?view=diff&rev=495930&r1=495929&r2=495930 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/StyledEditorKit.java Sat Jan 13 09:28:51 2007 @@ -358,9 +358,6 @@ protected void createInputAttributes(final Element element, final MutableAttributeSet set) { - if (element == null || set == null) { - return; - } AttributeSet as = element.getAttributes(); set.removeAttributes(set); for (Enumeration keys = as.getAttributeNames(); Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java?view=diff&rev=495930&r1=495929&r2=495930 ============================================================================== --- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java (original) +++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/StyledEditorKitTest.java Sat Jan 13 09:28:51 2007 @@ -20,9 +20,12 @@ */ package javax.swing.text; +import java.util.Enumeration; + import javax.swing.Action; import javax.swing.JEditorPane; import javax.swing.SwingTestCase; +import javax.swing.event.ChangeListener; public class StyledEditorKitTest extends SwingTestCase { StyledEditorKit kit; @@ -280,4 +283,99 @@ public void testInstallJEditorPane() { } + + + + /** + * Regression test for HARMONY-2594 + * */ + public void testcreateInputAttributes() { + MyStyledEditorKit msek = new MyStyledEditorKit(); + MutableAttributeSet set = new Style() { + public void removeChangeListener(ChangeListener p0) { + return; + } + public void addChangeListener(ChangeListener p0) { + return; + } + public String getName() { + return "AA"; + } + public void setResolveParent(AttributeSet p0) { + return; + } + public void removeAttributes(AttributeSet p0) { + return; + } + public void removeAttributes(Enumeration p0) { + return; + } + public void removeAttribute(Object p0) { + return; + } + public void addAttributes(AttributeSet p0) { + return; + } + public void addAttribute(Object p0, Object p1) { + return; + } + public AttributeSet getResolveParent() { + return null; + } + public boolean containsAttributes(AttributeSet p0) { + return false; + } + public boolean containsAttribute(Object p0, Object p1) { + return false; + } + public Enumeration getAttributeNames() { + return null; + } + public Object getAttribute(Object p0) { + return null; + } + public AttributeSet copyAttributes() { + return null; + } + public boolean isEqual(AttributeSet p0) { + return false; + } + public boolean isDefined(Object p0) { + return false; + } + public int getAttributeCount() { + return 0; + } + }; + try { + msek.createInputAttributes(null, set); + fail("NPE not thrown when Element is null!"); + } catch (NullPointerException npe) { + // expected + } + } + + /** + * Regression test for HARMONY-2594 + * */ + public void testCreateInputAttributes2() { + MyStyledEditorKit msek = new MyStyledEditorKit(); + try { + msek.createInputAttributes(new SimpleElement(""), null); + fail("NPE not thrown when MutableAttributeSet is null!"); + } catch (NullPointerException npe) { + // expected + } + } + + class MyStyledEditorKit extends StyledEditorKit { + public MyStyledEditorKit() { + super(); + } + + public void createInputAttributes(Element element, MutableAttributeSet set) { + super.createInputAttributes(element, set); + } + } + }