Am 26. Februar 2017 13:05:20 MEZ schrieb sebb <[email protected]>: >On 26 February 2017 at 08:41, Felix Schumacher ><[email protected]> wrote: >> Am 26.02.2017 um 09:06 schrieb Felix Schumacher: >>> >>> >>> Am 25. Februar 2017 23:42:44 MEZ schrieb sebb <[email protected]>: >>>> >>>> On 25 February 2017 at 14:25, Felix Schumacher >>>> <[email protected]> wrote: >>>>> >>>>> Am 25.02.2017 um 15:01 schrieb Philippe Mouawad: >>>>>> >>>>>> Hi Graham, >>>>>> It could be coming from a Sonar error I fixed in r1783482 >>>>>> >>>>>> @Override >>>>>> public String getName() { >>>>>> if (nameField != null) { >>>>>> return nameField.getText(); >>>>>> } >>>>>> return ""; // $NON-NLS-1$ >>>>>> } >>>>>> >>>>>> Could you try it ? >>>>> >>>>> I reverted the fix and added a sonar hint, to not nag us about >this. >>>> >>>> I doubt that this is the full solution. >>>> If the nameField can be null here then it can perhaps be null in >>>> setName. >>>> >>>> The underlying cause of the issue needs to be found. >>>> >>>> One problem I notice is that the NamePanel ctor calls setName() >which >>>> can be overridden - that can cause issues because the object won't >be >>>> fully constructed until the ctor completes. >>>> This is why init() is private. >>>> The setName() code either needs to be duplicated in init(), or it >>>> could be put into a private method called by the ctor and the >public >>>> setName. >>> >>> Your analysis is correct, that setName should not be used in the >ctor as >>> it could be modified in subclasses. >>> >>> I tried a variant first, where I inlined the functionality of >setName into >>> the ctor. >>> >>> That didn't help. > >Yeah, I realise now that will only help sub-classes of NamePanel. >But it still needs to be fixed. > >I had not considered that the JVM would have the same fault. > >>> >>> We could add a safe guard into setName just in case and for >symmetry. > >Not necessary unless setName() is called by the JPanel ctor directly >or indirectly. > >> Btw, the stacktrace is: >> >> java.lang.NullPointerException: null >> at org.apache.jmeter.gui.NamePanel.getName(NamePanel.java:78) >> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at >com.sun.java.swing.plaf.gtk.GTKStyle.getInsets(GTKStyle.java:316) >> ~[?:1.8.0_121] >> at >> >javax.swing.plaf.synth.SynthStyle.installDefaults(SynthStyle.java:913) >> ~[?:1.8.0_121] >> at >> >javax.swing.plaf.synth.SynthLookAndFeel.updateStyle(SynthLookAndFeel.java:265) >> ~[?:1.8.0_121] >> at >> >javax.swing.plaf.synth.SynthPanelUI.updateStyle(SynthPanelUI.java:117) >> ~[?:1.8.0_121] >> at >> >javax.swing.plaf.synth.SynthPanelUI.installDefaults(SynthPanelUI.java:100) >> ~[?:1.8.0_121] >> at >javax.swing.plaf.basic.BasicPanelUI.installUI(BasicPanelUI.java:56) >> ~[?:1.8.0_121] >> at >javax.swing.plaf.synth.SynthPanelUI.installUI(SynthPanelUI.java:62) >> ~[?:1.8.0_121] >> at javax.swing.JComponent.setUI(JComponent.java:666) >~[?:1.8.0_121] >> at javax.swing.JPanel.setUI(JPanel.java:153) ~[?:1.8.0_121] >> at javax.swing.JPanel.updateUI(JPanel.java:126) ~[?:1.8.0_121] >> at javax.swing.JPanel.<init>(JPanel.java:86) ~[?:1.8.0_121] >> at javax.swing.JPanel.<init>(JPanel.java:109) ~[?:1.8.0_121] >> at javax.swing.JPanel.<init>(JPanel.java:117) ~[?:1.8.0_121] >> at org.apache.jmeter.gui.NamePanel.<init>(NamePanel.java:44) >> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at >> >org.apache.jmeter.gui.AbstractJMeterGuiComponent.<init>(AbstractJMeterGuiComponent.java:78) >> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at >org.apache.jmeter.control.gui.TestPlanGui.<init>(TestPlanGui.java:68) >> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at >> >org.apache.jmeter.gui.tree.JMeterTreeModel.<init>(JMeterTreeModel.java:49) >> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at org.apache.jmeter.JMeter.startGui(JMeter.java:366) >> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at org.apache.jmeter.JMeter.start(JMeter.java:519) >> [ApacheJMeter_core.jar:3.2-SNAPSHOT.20170226] >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> ~[?:1.8.0_121] >> at >> >sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) >> ~[?:1.8.0_121] >> at >> >sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) >> ~[?:1.8.0_121] >> at java.lang.reflect.Method.invoke(Method.java:498) >~[?:1.8.0_121] >> at org.apache.jmeter.NewDriver.main(NewDriver.java:256) >> [ApacheJMeter.jar:3.2-SNAPSHOT.20170226] >> >> So, if I understand it correctly. The superclass will get initialized >before >> ourselves and that ctor will call into the laf system, which calls >the >> getName method (which we have overridden). At that time (init of ctor >of >> super) our fields will not have initialized, which leads to the NPE. > >That seems to be the case here. > >However I'm not sure that there any guarantees of the order of >initialisation. >What is guaranteed is that initialisation will be completed when the >ctor exits. >Whilst the ctor is still being executed there's not telling what state >classes will be in. > >> So, I think the problem lies in the gtk+ implementation of laf, which >is >> calling an overridable method in the ctor. > >It does look as though the GTK+ ctor calls an overrideable method. >So it is broken; the problem needs to be reported and fixed as it >won't only affect JMeter.
I have submitted a bug report. It can be found at http://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8175888 Regards, Felix > >It's not possible for subclasses of JPanel to reliably fix the problem >since there's no knowing what parts of the class have been initialised >and which have not. > >The best subclasses can do is add protection against some failures, >such as the NPE here. > >But that is a hack, and should not be released unless absolutely >necessary. >And in that case the code must be carefully documented to explain why >the code does what it does and when the work-round can be removed. > >Also, the fact that the ctor calls getName presumably means it needs >to obtain the value in order to complete its own init. >How does the subclass return the correct value? > >> Regards, >> Felix >> >> >>> >>> Felix >>> >>>>> Felix >>>>> >>>>> >>>>>> Thanks >>>>>> >>>>>> On Sat, Feb 25, 2017 at 2:42 PM, Graham Russell ><[email protected]> >>>> >>>> wrote: >>>>>>> >>>>>>> Hi all >>>>>>> >>>>>>> I just tried to run `ant run_gui` on the latest (github) trunk >but >>>>>>> this results in an NPE - specifically when trying to create the >>>>>>> JMeterTreeModel. >>>>>>> >>>>>>> Any ideas? >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> Graham >>>>>>> >>>>>>> The JMeter log is: >>>>>>> >>>>>>> 2017-02-25 13:26:50,223 INFO o.a.j.u.JMeterUtils: Setting Locale >to >>>> >>>> en_GB >>>>>>> >>>>>>> 2017-02-25 13:26:50,246 INFO o.a.j.JMeter: Loading user >properties >>>>>>> from: /home/coding/jmeter/bin/user.properties >>>>>>> 2017-02-25 13:26:50,247 INFO o.a.j.JMeter: Loading system >>>> >>>> properties >>>>>>> >>>>>>> from: /home/coding/jmeter/bin/system.properties >>>>>>> 2017-02-25 13:26:50,317 INFO o.a.j.JMeter: Copyright (c) >1998-2017 >>>> >>>> The >>>>>>> >>>>>>> Apache Software Foundation >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: Version >>>> >>>> 3.2-SNAPSHOT.20170225 >>>>>>> >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: >java.version=1.8.0_121 >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: java.vm.name=Java >>>>>>> HotSpot(TM) 64-Bit Server VM >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: os.name=Linux >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: os.arch=amd64 >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: >>>> >>>> os.version=4.4.0-59-generic >>>>>>> >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: file.encoding=UTF-8 >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: Max memory >>>> >>>> =1342177280 >>>>>>> >>>>>>> 2017-02-25 13:26:50,318 INFO o.a.j.JMeter: Available Processors >=4 >>>>>>> 2017-02-25 13:26:50,323 INFO o.a.j.JMeter: Default >Locale=English >>>>>>> (United Kingdom) >>>>>>> 2017-02-25 13:26:50,323 INFO o.a.j.JMeter: JMeter >Locale=English >>>>>>> (United Kingdom) >>>>>>> 2017-02-25 13:26:50,323 INFO o.a.j.JMeter: >>>> >>>> JMeterHome=/home/coding/jmeter >>>>>>> >>>>>>> 2017-02-25 13:26:50,323 INFO o.a.j.JMeter: user.dir >>>> >>>> =/home/coding/jmeter >>>>>>> >>>>>>> 2017-02-25 13:26:50,323 INFO o.a.j.JMeter: PWD >>>> >>>> =/home/coding/jmeter >>>>>>> >>>>>>> 2017-02-25 13:26:50,324 INFO o.a.j.JMeter: IP: 127.0.1.1 Name: >>>>>>> EliteBook FullName: EliteBook >>>>>>> 2017-02-25 13:26:50,607 INFO o.a.j.g.a.LookAndFeelCommand: Using >>>> >>>> look >>>>>>> >>>>>>> and feel: com.sun.java.swing.plaf.gtk.GTKLookAndFeel [GTK+, >System] >>>>>>> 2017-02-25 13:26:50,805 INFO o.a.j.JMeter: Loaded icon >properties >>>> >>>> from >>>>>>> >>>>>>> org/apache/jmeter/images/icon.properties >>>>>>> 2017-02-25 13:26:50,842 ERROR o.a.j.JMeter: An error occurred: >>>>>>> java.lang.NullPointerException: null >>>>>>> at >>>> >>>> org.apache.jmeter.gui.NamePanel.getName(NamePanel.java:75) >>>>>>> >>>>>>> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at >>>> >>>> com.sun.java.swing.plaf.gtk.GTKStyle.getInsets(GTKStyle. >>>>>>> >>>>>>> java:316) >>>>>>> ~[?:1.8.0_121] >>>>>>> at javax.swing.plaf.synth.SynthStyle.installDefaults( >>>>>>> SynthStyle.java:913) >>>>>>> ~[?:1.8.0_121] >>>>>>> at >javax.swing.plaf.synth.SynthLookAndFeel.updateStyle( >>>>>>> SynthLookAndFeel.java:265) >>>>>>> ~[?:1.8.0_121] >>>>>>> at javax.swing.plaf.synth.SynthPanelUI.updateStyle( >>>>>>> SynthPanelUI.java:117) >>>>>>> ~[?:1.8.0_121] >>>>>>> at >javax.swing.plaf.synth.SynthPanelUI.installDefaults( >>>>>>> SynthPanelUI.java:100) >>>>>>> ~[?:1.8.0_121] >>>>>>> at javax.swing.plaf.basic.BasicPanelUI.installUI( >>>>>>> BasicPanelUI.java:56) >>>>>>> ~[?:1.8.0_121] >>>>>>> at javax.swing.plaf.synth.SynthPanelUI.installUI( >>>>>>> SynthPanelUI.java:62) >>>>>>> ~[?:1.8.0_121] >>>>>>> at javax.swing.JComponent.setUI(JComponent.java:666) >>>>>>> ~[?:1.8.0_121] >>>>>>> at javax.swing.JPanel.setUI(JPanel.java:153) >>>> >>>> ~[?:1.8.0_121] >>>>>>> >>>>>>> at javax.swing.JPanel.updateUI(JPanel.java:126) >>>> >>>> ~[?:1.8.0_121] >>>>>>> >>>>>>> at javax.swing.JPanel.<init>(JPanel.java:86) >>>> >>>> ~[?:1.8.0_121] >>>>>>> >>>>>>> at javax.swing.JPanel.<init>(JPanel.java:109) >>>> >>>> ~[?:1.8.0_121] >>>>>>> >>>>>>> at javax.swing.JPanel.<init>(JPanel.java:117) >>>> >>>> ~[?:1.8.0_121] >>>>>>> >>>>>>> at >>>> >>>> org.apache.jmeter.gui.NamePanel.<init>(NamePanel.java:44) >>>>>>> >>>>>>> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at >>>> >>>> org.apache.jmeter.gui.AbstractJMeterGuiComponent.<init>( >>>>>>> >>>>>>> AbstractJMeterGuiComponent.java:78) >>>>>>> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at org.apache.jmeter.control.gui.TestPlanGui.<init>( >>>>>>> TestPlanGui.java:68) >>>>>>> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at org.apache.jmeter.gui.tree.JMeterTreeModel.<init>( >>>>>>> JMeterTreeModel.java:49) >>>>>>> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at org.apache.jmeter.JMeter.startGui(JMeter.java:366) >>>>>>> ~[ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at org.apache.jmeter.JMeter.start(JMeter.java:519) >>>>>>> [ApacheJMeter_core.jar:3.2-SNAPSHOT.20170225] >>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native >>>> >>>> Method) >>>>>>> >>>>>>> ~[?:1.8.0_121] >>>>>>> at sun.reflect.NativeMethodAccessorImpl.invoke( >>>>>>> NativeMethodAccessorImpl.java:62) >>>>>>> ~[?:1.8.0_121] >>>>>>> at sun.reflect.DelegatingMethodAccessorImpl.invoke( >>>>>>> DelegatingMethodAccessorImpl.java:43) >>>>>>> ~[?:1.8.0_121] >>>>>>> at java.lang.reflect.Method.invoke(Method.java:498) >>>>>>> ~[?:1.8.0_121] >>>>>>> at >org.apache.jmeter.NewDriver.main(NewDriver.java:256) >>>>>>> [ApacheJMeter.jar:3.2-SNAPSHOT.20170225] >>>>>>> >>>>>> >>
