Project

General

Profile

bug #7728

NPE in wizard when changing type of reference

Added by Katja Luther 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
New
Category:
taxeditor
Target version:
Start date:
09/06/2018
Due date:
% Done:

50%

Severity:
normal
Found in Version:

Description

Hallo Katja,

Beim Öffnen einer In-Referenz einer Referenz, die selber bereits im Dialog geöffnet ist, kam reproduzierbar folgender Fehler.
Kannst du mal sehen, ob offensichtlich ist, woran das liegen kann. Beide Referenzen sind preliminary.

Leider ist DB derzeit noch lokal nur bei mir.

Wie es mir scheint, liegt es aber daran, dass colors nicht gesetzt ist an dieser Stelle. Wie kann man sicherstellen, dass colors immer einen Wert hat?
form.setBackground(colors.getBackground());

Viele Grüße,
Andreas M.

login : admin
editor version : 5.3.0.201808280657
server : localhost (localhost mgd.)
schema version : 5.0.0.0.20180514
os : Windows Server 2012 R2 6.3 amd64
java : 1.8.0_121
java.lang.NullPointerException
                at org.eclipse.ui.forms.widgets.FormToolkit.createScrolledForm(FormToolkit.java:668)
                at eu.etaxonomy.taxeditor.ui.element.AbstractCdmEntityWizardPage.createControl(AbstractCdmEntityWizardPage.java:93)
                at eu.etaxonomy.taxeditor.ui.section.reference.ReferenceWizardPage.createControl(ReferenceWizardPage.java:49)
                at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:175)
                at org.eclipse.jface.wizard.WizardDialog.createPageControls(WizardDialog.java:696)
                at org.eclipse.jface.wizard.WizardDialog.createContents(WizardDialog.java:588)
                at org.eclipse.jface.window.Window.create(Window.java:426)
                at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:1095)
                at org.eclipse.jface.window.Window.open(Window.java:783)
                at eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement$EditListener.widgetSelected(EntitySelectionElement.java:439)
                at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
                at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
                at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
                at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
                at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
                at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
                at org.eclipse.jface.window.Window.runEventLoop(Window.java:818)
                at org.eclipse.jface.window.Window.open(Window.java:794)
                at eu.etaxonomy.taxeditor.ui.selection.EntitySelectionElement$EditListener.widgetSelected(EntitySelectionElement.java:439)
                at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:249)
                at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
                at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4418)
                at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1079)
                at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4236)
                at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3824)
                at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
                at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
                at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
                at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
                at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
                at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
                at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
                at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
                at eu.etaxonomy.taxeditor.Application.start(Application.java:24)
                at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
                at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
                at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
                at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
                at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
                at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                at java.lang.reflect.Method.invoke(Method.java:498)
                at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
                at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
                at org.eclipse.equinox.launcher.Main.run(Main.java:1519)

Associated revisions

Revision 656cc90a (diff)
Added by Patrick Plitzner 3 months ago

fix #7728 Fix initialisation of form toolkit in DateElement

Revision 7b690399 (diff)
Added by Patrick Plitzner 3 months ago

ref #7728 Removed unused toolkit member

History

#1 Updated by Katja Luther 3 months ago

This problem is caused by a cdmFormFactory which is set to disposed. at the moment we handle widget is disposed exceptions by setting the toolkit to disposed
But all elements of a view pointing to the same cdmFormFactory and so the CdmFormFactory of the view is disposed.
This results in a NPE when other elements of the view are changed and the view is updated therefore the toolkit is needed but the attribute colors is null because while setting the toolkit disposed this attribute is set to null.

I tried to just ignore the widget is disposed exception and do not set the toolkit disposed, but then sometimes the widgets are not fully updated.

#2 Updated by Patrick Plitzner 3 months ago

I cannot reproduce this. What exactly did you do?

I opened a taxon in the name editor -> Opened the reference wizard via "Edit" and then the in-reference via "Edit" but nothing happened.

#3 Updated by Katja Luther 3 months ago

open a reference and create a new inReference, set the type to webPage, after finish go back to the first reference and set the type to webPage. I think then you get the exception.

#4 Updated by Patrick Plitzner 3 months ago

Patrick Plitzner wrote:

I cannot reproduce this. What exactly did you do?

I opened a taxon in the name editor -> Opened the reference wizard via "Edit" and then the in-reference via "Edit" but nothing happened.

Ok, never mind. It has to be of type "Web Page"

#5 Updated by Patrick Plitzner 3 months ago

It actually does not have anything to do with which type you choose or if it is an in-reference. The error can be reproduces as follows:

  1. Open taxon in name editor
  2. Click on "Edit" reference in the details view
  3. Change the type to something else and close the wizard
  4. Click on "Edit" again in the details view

#6 Updated by Patrick Plitzner 3 months ago

  • Subject changed from NPE when editing webpage of webpage to NPE in wizard when changing type of reference

#7 Updated by Patrick Plitzner 3 months ago

Patrick Plitzner wrote:

It actually does not have anything to do with which type you choose or if it is an in-reference. The error can be reproduces as follows:

  1. Open taxon in name editor
  2. Click on "Edit" reference in the details view
  3. Change the type to something else and close the wizard
  4. Click on "Edit" again in the details view

Even worse: The NPE happens for every "Edit" wizard after having done step 1-3. I tested with Author for example

#8 Updated by Patrick Plitzner 3 months ago

The class DateElement has a DisposeListener that disposes of the cdmFormFactory. But this is not how it should be handled. See the extract of the JavaDoc of FormToolkit:

Typically, one toolkit object is created per workbench part (for example, an editor or a form wizard). The toolkit is disposed when the part is disposed. To conserve resources, it is possible to create one color object for the entire plug-in and share it between several toolkits. The plug-in is responsible for disposing the colors (disposing the toolkit that uses shared color object will not dispose the colors).

Every time the details view is rendered it creates a new cdmFormFactory and disposes of the old one. The exception in this case was thrown because the wizard gets the form factory of the details view. In the wizard a DateElement is used which has a DisposeListener registered that disposes of the cdmFormFactory:

        addDisposeListener(new DisposeListener() {
            @Override
            public void widgetDisposed(DisposeEvent e) {
                toolkit.dispose();
            }
        });

By doing so it disposes of the form factory for the entire details view.

There are other elements that also have a dispose listeners registered but they instantiate their own toolkit so this is correct.

Solution

Actually, the DateElement created its own toolkit as well but this was removed with this commit taxeditor|e38ddfeee4a59c876fedd950b64cb99147e4f865

I reverted the changes in this commit regarding the instantiation of the toolkit.

@Katja: Please review, especially check if there was a reason why the instantiation was changed to passing the form factory in the constructor. Maybe it was just a "copy & paste" error

#9 Updated by Patrick Plitzner 3 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50

#10 Updated by Patrick Plitzner 3 months ago

  • Assignee changed from Patrick Plitzner to Katja Luther

#11 Updated by Katja Luther 3 months ago

works fine. This was something like a copy&paste error because only the indention should be removed

#12 Updated by Katja Luther 3 months ago

  • Status changed from Resolved to Closed
  • Assignee changed from Katja Luther to Patrick Plitzner

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)