Community
Participate
Working Groups
If an error in ApplicationActionBarAdivosor-class occurs the application is just terminated, but does not throw an exception on console, even not in debug mode. Example: Save Action. When the save action is not created in the RCP's ActionBarAdvisor, but tried to be registered the application is just terminated. A possible solution might be: protected void register(IAction action) { try{ String id = action.getId(); // Assert.isNotNull(id, "Action must not have null id"); //$NON-NLS-1$ getActionBarConfigurer().registerGlobalAction(action); actions.put(id, action); } catch(NullPointerException e){ String message = "The to registered action element pointed to null."; //$NON-NLS-1$ WorkbenchPlugin.log(new Status(IStatus.ERROR, String.valueOf(WorkbenchPlugin.getDefault().getBundle().getBundleId()), message,e )); } }
I seem to be getting things in my console if I do something like register(null) in my ApplicationActionBarAdvisor's makeActions(IWorkbenchWindow) method on I20071009-2225. Also, is 206179 essentially a duplicate of this?
thanks for your quick reply! :) I don't get anything on my console, but something useful is logged. Nevertheless I think my proposal is: a.more descriptive to find out what was the cause 1.(my suggeston's log): !ENTRY 22 4 0 2007-10-13 11:53:57.093 !MESSAGE The to registered action element pointed to null. !STACK 0 java.lang.NullPointerException at org.eclipse.ui.application.ActionBarAdvisor.register(ActionBarAdvisor.java:190) at testsnady.ApplicationActionBarAdvisor.makeActions(ApplicationActionBarAdvisor.java:24) at org.eclipse.ui.application.ActionBarAdvisor.fillActionBars(ActionBarAdvisor.java:148) at org.eclipse.ui.internal.WorkbenchWindow.fillActionBars(WorkbenchWindow.java:3301) ... comparted to: !ENTRY org.eclipse.ui 4 0 2007-10-13 11:57:02.640 !MESSAGE Unhandled event loop exception !STACK 0 java.lang.NullPointerException at org.eclipse.ui.application.ActionBarAdvisor.register(ActionBarAdvisor.java:188) at testsnady.ApplicationActionBarAdvisor.makeActions(ApplicationActionBarAdvisor.java:24) at org.eclipse.ui.application.ActionBarAdvisor.fillActionBars(ActionBarAdvisor.java:147) at org.eclipse.ui.internal.WorkbenchWindow.fillActionBars(WorkbenchWindow.java:3301) b. and further more essential the application is not terminated, only because an action item could not be registerd. Maybe referring to this different opinions exists, but in my opinion that application should only be terminated if an error message is printed to the console. Concerning 206179 I I'll comment soon, again.
(In reply to comment #2) > I don't get anything on my console, but something useful is logged. Sorry, I don't understand. Your Eclipse console has nothing but you have things in your target runtime workspace's logs?
> Sorry, I don't understand. Your Eclipse console has nothing but you have things in your target runtime workspace's logs? Exactly. Any idea? Can you please comment 'b.', too.
(In reply to comment #4) > > Sorry, I don't understand. Your Eclipse console has nothing but you have things in your target runtime workspace's logs? > Exactly. Any idea? Well, as I mentioned, I have stuff in my logs. > Can you please comment 'b.', too. If an application terminates and errors are logged, I feel it's perfectly valid for it to terminate. I do not feel that it's necessary to spit output onto the console. Log files are there for a reason. Perhaps someone from the Platform team can comment on this, but this is just my own opinion.
First of all thanks for your replies. In general I agree with you concerning the logging, but referring to the high learning curve for getting familiar with eclipse (plug-in development /) RCP I thought for beginners this might be better. So, I keep up to you what is the better way concerning the reported bugs/enhancements!
Can you provide your build ID (Help -> About Eclipse SDK)? Also, can you provide the exact steps to reproduce the behaviour in question? If my application crashes because of an NPE, as far as I can remember, I've always had something in my console even if it is not a full stack trace. So the fact that you have nothing in your logs interests me.
1) Eclipse SDK, Version: 3.3.1, Build id: M20070921-1145. 2) Sorry, if I didn't express myself good, but I do get the NPEs in the '.log'-file. I only get neither sth on 'console view' nor on 'cmd line console'. 3) The procedure is the same as yours, just try to register 'null' or rather an IAction field which references 'null'. Concerning 206179 the procedure is alrieady delivered in the description.
If you put print statements before you cause your NPE, does it appear in the console?
Yes, they appear in the console.
If someone wants to submit a patch I'll consider it. appropriate is check for null and throw an IllegalArgumentException PW
Created attachment 81267 [details] Patch to check if the IAction is null.
Released to HEAD >20080408 PW
In I20080501-0100 PW