This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 169890 - NotificationDisplayer fails to handle null detailsAction
Summary: NotificationDisplayer fails to handle null detailsAction
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2009-08-05 13:14 UTC by andvicoso
Modified: 2009-10-15 10:23 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description andvicoso 2009-08-05 13:14:47 UTC
In the NotificationDisplayer javadoc, inside the notify method text (
http://bits.netbeans.org/dev/javadoc/org-openide-awt/org/openide/awt/NotificationDisplayer.html ) it is written:
"detailsAction - Action to invoke when user click details text or null.", but that is not correct! If I try to pass null
to the method, I receive the following error:"NullPointerException: detailsAction cannot be null.";
Comment 1 Geertjan Wielenga 2009-10-08 13:11:42 UTC
Jesse, can you verify whether this is true? Or reassign to whoever can do that?
Comment 2 Jesse Glick 2009-10-08 16:15:55 UTC
The API as defined since 6.7 onwards does specifically say null is permitted for detailsAction. It is the implementation
which is incorrect. Suggest something like the following (untested):

diff --git a/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java
b/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java
--- a/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java
+++ b/core.ui/src/org/netbeans/core/ui/notifications/NotificationDisplayerImpl.java
@@ -65,6 +65,7 @@
 import javax.swing.SwingUtilities;
 import org.openide.awt.Notification;
 import org.openide.awt.NotificationDisplayer;
+import org.openide.util.Exceptions;
 import org.openide.util.Lookup;
 import org.openide.util.lookup.ServiceProvider;
 import org.openide.xml.XMLUtil;
@@ -93,14 +94,7 @@
     public Notification notify(String title, Icon icon, String detailsText, ActionListener detailsAction, Priority
priority) {
         if( null == detailsText )
             throw new NullPointerException("detailsText cannot be null."); //NOI18N
-        if( null == detailsAction )
-            throw new NullPointerException("detailsAction cannot be null."); //NOI18N
 
-        try {
-            detailsText = XMLUtil.toElementContent(detailsText);
-        } catch( CharConversionException ex ) {
-            throw new IllegalArgumentException(ex);
-        }
         JComponent detailsComp1 = createDetails( detailsText, detailsAction );
         JComponent detailsComp2 = createDetails( detailsText, detailsAction );
 
@@ -242,7 +236,14 @@
     }
 
     private JComponent createDetails( String text, ActionListener action ) {
-        text = "<html><u>" + text; //NOI18N
+        if (action == null) {
+            return new JLabel(text);
+        }
+        try {
+            text = "<html><u>" + XMLUtil.toElementContent(detailsText); // NOI18N
+        } catch( CharConversionException ex ) {
+            Exceptions.printStackTrace(ex);
+        }
         JButton btn = new JButton(text);
         btn.setFocusable(false);
         btn.setBorder(BorderFactory.createEmptyBorder());
Comment 3 Stanislav Aubrecht 2009-10-09 17:40:19 UTC
fixed as suggested

core-main 7058b68701ea
Comment 4 Quality Engineering 2009-10-15 10:23:56 UTC
Integrated into 'main-golden', will be available in build *200910150201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/7058b68701ea
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #169890 - NotificationDisplayer fails to handle null detailsAction