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 30947 - ErrorManager.notify(Throwable) w/o sev -> sev = EXCEPTION, should be autodetect
Summary: ErrorManager.notify(Throwable) w/o sev -> sev = EXCEPTION, should be autodetect
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jesse Glick
URL:
Keywords: UI
Depends on: 31254
Blocks: 28990
  Show dependency tree
 
Reported: 2003-02-11 14:00 UTC by ehucka
Modified: 2008-12-23 11:22 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
FSException's stack trace. (1.97 KB, text/html)
2003-02-11 14:02 UTC, ehucka
Details
exception stacktrace (1.78 KB, text/plain)
2003-02-20 15:48 UTC, pzajac
Details
A proposed hot fix. (545 bytes, patch)
2003-02-26 14:13 UTC, David Strupl
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ehucka 2003-02-11 14:00:52 UTC
Build 200302110100
Linux RH 7.2
JDK 1.4.1

Steps to reproduce:

I have 2 java files in one package. 
I want to rename one to other's name (removing).
It only throws FSException and files stay as before.
Comment 1 ehucka 2003-02-11 14:02:10 UTC
Created attachment 8895 [details]
FSException's stack trace.
Comment 2 Marian Mirilovic 2003-02-11 15:24:47 UTC
Hmm, there should be some informational exception thrown , that file
already esists.
IMHO: your attached exception is only annotation,
IllegalArgumentException arises ( so maybe only detect why it is
impossible to copy file - and inform user about purpose - I am not
sure it is possible to implement this detection )
Comment 3 ehucka 2003-02-11 15:35:11 UTC
I think there should invokes some YES/NO type dialog with question if
a user wants to overwrite (replace) existing file.

Good file management is a base of user contentment.:)
Comment 4 pzajac 2003-02-18 09:22:58 UTC
I think, that YES|NO dialog isn't necessary. But the exception must be
correctly annotated. 
 I think that better and faster editor is for IDE mere important than
confirmation dialog "target file allready exists<Oweride> <cancel>,
isn't it. 
  
Comment 5 rmatous 2003-02-20 14:49:47 UTC
I don't consider this issue as a bug. Behaviour is OK and exception is
corectly annotated. java.io.File.rename returns true or false if
rename succeeds or not. There is no additional information. I don't
think there is necessary to do additional check and try to predict cause.
Comment 6 pzajac 2003-02-20 15:17:16 UTC
incorrect annotation of exception. 
Comment 7 pzajac 2003-02-20 15:18:14 UTC
build [200302200100]
Comment 8 pzajac 2003-02-20 15:48:58 UTC
Created attachment 9060 [details]
exception stacktrace
Comment 9 pzajac 2003-02-20 16:00:33 UTC
Hm, there is maybe problem in error manager. The exception is
annotated correctly as WARNIGN. But in ErrorManager is probably
incorrectly notified. 
David, can you evaluate this exception?
Comment 10 David Strupl 2003-02-23 22:59:37 UTC
If the annotation is of type warning the correct dialog 
should pop up (if the notification is standard). The 
problem can be in ErrorManager or in the call to 
ErrorManager while notifying it.
Comment 11 David Strupl 2003-02-26 14:13:06 UTC
Created attachment 9167 [details]
A proposed hot fix.
Comment 12 David Strupl 2003-02-26 15:29:30 UTC
I am sorry I have attached the patch to the wrong issue.
Comment 13 pzajac 2003-02-27 15:16:05 UTC
David, the exception is annotated as USER. I  wrOte small test:

        ErrorManager em = ErrorManager.getDefault();
        Exception e = new Exception (" .....");
        em.notify(ErrorManager.USER, e);

It shows notify exception dialog. 
Comment 14 David Strupl 2003-02-27 15:24:08 UTC
Jesse, it seems that notifying in ErrorManager is seriously broken. If
you have an exception annotated with say warning severity and call
regular notify(e) the severity is EXCEPTION. It breaks code on several
places. Also please check Petr's example. Could you please evaluate?
Comment 15 Jesse Glick 2003-02-27 20:41:27 UTC
Yes, I know. Severity of nested annotations is actually ignored. The
only important thing is the severity you notify with. Unfortunate, but
(1) it has been this way forever IIRC and changing it now would
probably break other stuff; (2) the API design is very muddled and
does not really provide a clear solution. There are multiple places
where a severity may be set, and there is no rule I can think of for
composing them logically. I don't like it at all but I have thought
about it before and can't think of any safe way to solve it besides an
incompatible rewrite of the ErrorManager API.

So, the code calling notify needs to decide on an appropriate
severity. It can either hardcode this - e.g. USER in this case - or do
some sort of heuristic search through nested annotations and try to
retrieve some severity from them. Frankly I have no idea what the
desired behavior is in general.
Comment 16 David Strupl 2003-03-05 14:59:46 UTC
Back to you again ...
Comment 17 Jesse Glick 2003-03-05 17:13:15 UTC
Apparently EM.notify(Throwable) with no explicit severity needs to run
code which automatically extracts a severity from annotations.
Comment 18 David Strupl 2003-03-06 14:54:44 UTC
*** Issue 31254 has been marked as a duplicate of this issue. ***
Comment 19 Jesse Glick 2003-03-10 16:22:52 UTC
Probably can be treated as P2.
Comment 20 Jesse Glick 2003-03-10 19:52:21 UTC
Have patch which works on unit test anyway.

To Petr:

        ErrorManager em = ErrorManager.getDefault();
        Exception e = new Exception (" .....");
        em.notify(ErrorManager.USER, e);

This code *should* show an exception dialog. You need a localized
annotation for it to display nicely.
Comment 21 Jesse Glick 2003-03-10 20:12:18 UTC
Interestingly RenameAction & TreeViewCellEditor do not use exactly the
same algorithm for determining when to add localized annotations; or
specifically, one notifies with USER severity and the other with
unspecified severity. So they will behave a bit differently (different
dialog icons) for the original test case but otherwise be OK.
Comment 22 Jesse Glick 2003-03-11 19:29:19 UTC
Prep work:

committed   * Up-To-Date  1.7        
ant/src/org/apache/tools/ant/module/api/DefinitionRegistry.java
committed   * Up-To-Date  1.14       
ant/src/org/apache/tools/ant/module/api/IntrospectedInfo.java
committed   * Up-To-Date  1.16       
ant/src/org/apache/tools/ant/module/run/OutputWriterOutputStream.java
committed   * Up-To-Date  1.3        
core/javahelp/src/org/netbeans/modules/javahelp/AbstractHelp.java
committed   * Up-To-Date  1.8        
core/javahelp/src/org/netbeans/modules/javahelp/HelpAction.java
committed   * Up-To-Date  1.17       
core/src/org/netbeans/core/modules/Events.java
committed   * Up-To-Date  1.48       
core/src/org/netbeans/core/modules/Module.java
committed   * Up-To-Date  1.47       
core/src/org/netbeans/core/modules/ModuleList.java
committed   * Up-To-Date  1.57       
core/src/org/netbeans/core/modules/ModuleManager.java
committed   * Up-To-Date  1.4        
cpp/src/org/netbeans/modules/cpp/builds/OutputWindowOutputStream.java
committed   * Up-To-Date  1.2         logger/tests/mod16/Mod16Main.java
committed   * Up-To-Date  1.27       
openide/src/org/openide/actions/MoveUpAction.java
committed   * Up-To-Date  1.33       
openide/src/org/openide/util/HelpCtx.java
committed   * Up-To-Date  1.2        
testtools/src/org/netbeans/modules/testtools/OutputWriterOutputStream.java
committed   * Up-To-Date  1.6        
tomcatint/tomcat5/src/org/netbeans/modules/tomcat5/Tomcat5DO.java
committed   * Up-To-Date  1.4        
tomcatint/tomcat5/src/org/netbeans/modules/tomcat5/Tomcat5WebServer.java
committed   * Up-To-Date  1.13       
web/jspsyntax/src/org/netbeans/modules/web/core/syntax/JspSyntaxSupport.java
Comment 23 Jesse Glick 2003-03-11 19:31:40 UTC
Then fix itself:

committed   * Up-To-Date  1.50       
core/src/org/netbeans/core/NbErrorManager.java
committed   * Up-To-Date  1.3        
core/test/unit/src/org/netbeans/core/NbErrorManagerTest.java
committed   * Up-To-Date  1.26       
openide/src/org/openide/ErrorManager.java
Comment 24 Jesse Glick 2003-03-11 21:16:35 UTC
Merged a much simplified version that does not fix everything that the
trunk version fixed, just fixes the regression introduced by the fix
for issue #28990. It at least does work as desired for the case of the
attempted renaming of a Java file in a package to an existing name -
only a polite message is displayed. Trunk version also:

- gets rid of usage of UNKNOWN for logging, reserving it only for
notification

- implements searching for severities in nested annotations as well as
the main one (helpful for rethrowing)

- makes some fixes in handling of localized annotations, especially
nested ones

- includes an expanded test case

committed   * Up-To-Date  1.49.2.1   
core/src/org/netbeans/core/NbErrorManager.java
committed   * Up-To-Date  1.25.2.1   
openide/src/org/openide/ErrorManager.java
Comment 25 pzajac 2003-03-12 09:46:31 UTC
Verified. The exception annotations are correctly shown in 200303120350.
Comment 26 Terry Heatlie 2003-03-13 18:04:34 UTC
Maybe I've misunderstood, but in the 3.5 branch,

            NullPointerException npe = new NullPointerException("test");
            err.annotate(npe, ErrorManager.EXCEPTION, "foo", "bar",
new Exception(), new Date());
            err.notify(npe);

doesn't notify.  I'd have thought it should, since
err.isNotifiable(ErrorManager.EXCEPTION) == true.
Comment 27 Jesse Glick 2003-03-13 20:31:47 UTC
What doesn't notify? I am unaware of any problem. In r35 branch, I run
with internal execution:

import java.util.Date;
import org.openide.ErrorManager;
public class Foo {
    public static void main(String[] args) {
        ErrorManager err = ErrorManager.getDefault();
        NullPointerException npe = new NullPointerException("test");
        err.annotate(npe, ErrorManager.EXCEPTION, "foo", "bar", new
Exception(), new Date());
        err.notify(npe);
    }
}

and an exception dialog appears saying "bar" with a stack trace
available showing the main and nested exception. If you think there is
some other problem somewhere, please file it separately with complete
details to reproduce.
Comment 28 Terry Heatlie 2003-03-13 22:19:27 UTC
Oh dear.  Jesse is (of course) right; I was wrong.  I tried this
in a fresh build of the IDE and it worked perfectly.  I must have
had a corrupt/out-of-date build before.

Sorry for the false alarm.
Comment 29 Jan Becicka 2003-04-09 15:28:52 UTC
Reopening. I think that this issue still persist (at least my original
issue 31254 is still reproducible) in S1S 030408.


Comment 30 Jesse Glick 2003-04-09 16:35:36 UTC
Keeping it open in issue #31254 instead, for tracking purposes.
Comment 31 ehucka 2003-07-14 08:53:38 UTC
Verified.