You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jmeter.apache.org by Mingun <gi...@git.apache.org> on 2018/08/02 06:59:35 UTC

[GitHub] jmeter pull request #394: Fix IllegalArgumentException for File properties w...

GitHub user Mingun opened a pull request:

    https://github.com/apache/jmeter/pull/394

    Fix IllegalArgumentException for File properties wich allow null value

    ## Description
    This fix the `IllegalArgumentException` when `TestBean` class contains nullable `File` field (in my case field has name `vendorSKPath`):
    ```
    2018-08-02 11:42:54,940 DEBUG o.a.j.t.g.GenericTestBeanCustomizer: Property vendorSKPath has editor class null
    2018-08-02 11:42:54,941 DEBUG o.a.j.t.g.WrapperEditor: <-java.lang.String:
    2018-08-02 11:42:54,941 DEBUG o.a.j.t.g.WrapperEditor: ->""
    2018-08-02 11:42:54,941 DEBUG o.a.j.t.g.GenericTestBeanCustomizer: Property vendorSKPath has property editor org.apache.jmeter.testbeans.gui.FileEditor@1f236f6d
    2018-08-02 11:42:54,941 DEBUG o.a.j.t.g.WrapperEditor: <-NULL:null
    2018-08-02 11:42:54,941 WARN o.a.j.g.a.Load: Unexpected error. java.lang.IllegalArgumentException
    java.lang.IllegalArgumentException: null
    	at org.apache.jmeter.testbeans.gui.FieldStringEditor.setValue(FieldStringEditor.java:82) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.testbeans.gui.WrapperEditor.setValue(WrapperEditor.java:349) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.testbeans.gui.FileEditor.setValue(FileEditor.java:214) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.setEditorValue(GenericTestBeanCustomizer.java:477) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.<init>(GenericTestBeanCustomizer.java:289) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.testbeans.gui.TestBeanGUI.init(TestBeanGUI.java:417) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.testbeans.gui.TestBeanGUI.configure(TestBeanGUI.java:299) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.tree.JMeterTreeModel.addComponent(JMeterTreeModel.java:159) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:133) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:133) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:133) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:125) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.GuiPackage.addSubTree(GuiPackage.java:522) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:193) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:130) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.Load.loadProjectFile(Load.java:101) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.LoadRecentProject.doActionAfterCheck(LoadRecentProject.java:67) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.AbstractActionWithNoRunningTest.doAction(AbstractActionWithNoRunningTest.java:45) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.ActionRouter.performAction(ActionRouter.java:88) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at org.apache.jmeter.gui.action.ActionRouter.lambda$actionPerformed$0(ActionRouter.java:70) ~[ApacheJMeter_core.jar:4.1-SNAPSHOT.20180802]
    	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311) [?:1.8.0_181]
    	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758) [?:1.8.0_181]
    	at java.awt.EventQueue.access$500(EventQueue.java:97) [?:1.8.0_181]
    	at java.awt.EventQueue$3.run(EventQueue.java:709) [?:1.8.0_181]
    	at java.awt.EventQueue$3.run(EventQueue.java:703) [?:1.8.0_181]
    	at java.security.AccessController.doPrivileged(Native Method) [?:1.8.0_181]
    	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74) [?:1.8.0_181]
    	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728) [?:1.8.0_181]
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205) [?:1.8.0_181]
    	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116) [?:1.8.0_181]
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105) [?:1.8.0_181]
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101) [?:1.8.0_181]
    	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93) [?:1.8.0_181]
    	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82) [?:1.8.0_181]
    ```
    
    ```java
    public class WithFile implements TestBean {
        File file;
        public void setFile(File file) { this.file = file; }
        public File getFile() { return file; }
    }
    
    public class WithFileBeanInfo extends BeanInfoSupport {
        public WithFileBeanInfo() {
            super(WithFile.class);
            property("file");
        }
    }
    ```
    
    ## Motivation and Context
    Though in the comment to the class `FieldStringEditor` it is told that it processes only non-null strings:
    https://github.com/apache/jmeter/blob/0a6f36c6e3c6043587c7765103b1d22354bb55bc/src/core/org/apache/jmeter/testbeans/gui/FieldStringEditor.java#L29-L37
    
    the class `WrappedEditor` can call `setValue` with `null`:
    https://github.com/apache/jmeter/blob/0a6f36c6e3c6043587c7765103b1d22354bb55bc/src/core/org/apache/jmeter/testbeans/gui/WrapperEditor.java#L332-L349
    
    So I think that comment also need to be updated, but I am not sure. It is possible that this class as envisioned shall not allow `null` and it is necessary to do fix in other place, but in case of my testing this fix works fine.
    
    ## How Has This Been Tested?
    Create plugin with any `TestBean` class with nullable `File` field as show above
    
    ## Types of changes
    - Bug fix (non-breaking change which fixes an issue)
    
    ## Checklist:
    - [x] My code follows the [code style][style-guide] of this project.
    - [ ] I have updated the documentation accordingly.
    
    [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Mingun/jmeter fix-null-in-field

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/jmeter/pull/394.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #394
    
----
commit 74954718509847375e7aee6ba429ec5e9619f5c2
Author: Mingun <al...@...>
Date:   2018-08-02T06:11:29Z

    Fix IllegalArgumentException for File properties wich allow null value

----


---

[GitHub] jmeter pull request #394: Fix IllegalArgumentException for File properties w...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/jmeter/pull/394


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by FSchumacher <gi...@git.apache.org>.
Github user FSchumacher commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    Thanks for your contribution and the detailed description.
    Is there any reason, that you don't want to specify a default value for a property that can be undefined? Look for example at `Example3BeanInfo.java`.
    Other than that it seems OK to include the patch, as there is a code path into `FieldStringEditor` that would allow `null` values.


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by Mingun <gi...@git.apache.org>.
Github user Mingun commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    Any news?


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by Mingun <gi...@git.apache.org>.
Github user Mingun commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    Now its ready to merge. Travis fail is unrelated to this changes


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by Mingun <gi...@git.apache.org>.
Github user Mingun commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    In my plugin it is filepath that enable optional feature, so when it is undefined the feature is off.
    
    In the next 2 weeks I will not be able to work on PR since I am on vacation, therefore if any additional work are required, then be not surprised that I will answer not soon.


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by FSchumacher <gi...@git.apache.org>.
Github user FSchumacher commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    OK, so we really have to explicitly allow `null` to help you there, right? Does the last change help you?


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by Mingun <gi...@git.apache.org>.
Github user Mingun commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    Thanks!
    
    I was tested with 2c82bf31db1110919e9ab84b13ab6c4f15d92ac5 (trunk branch). The exception does not arise any more though to set *Undefined* value for File property is impossible now, even though the flag {{NOT_UNDEFINED}} is not set for property. I attach 2 screenshots showing behavior of the same plugin file in versions 3.1 and 5.1:
    ![jmeter 3 x](https://user-images.githubusercontent.com/450131/46124740-415ad480-c23f-11e8-89bd-58d0f2ac73b3.png)
    ![jmeter 5 x](https://user-images.githubusercontent.com/450131/46124742-415ad480-c23f-11e8-9435-d56dc8dabab0.png)
    
    Therefore this fix so far not really helps me


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by FSchumacher <gi...@git.apache.org>.
Github user FSchumacher commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    I have modified your code slightly where I think it helps readability. It should contain no functional difference to your code. It would be nice, if you could test the next nightly or current trunk.
    
    Thanks again for your contribution.


---

[GitHub] jmeter issue #394: Fix IllegalArgumentException for File properties wich all...

Posted by Mingun <gi...@git.apache.org>.
Github user Mingun commented on the issue:

    https://github.com/apache/jmeter/pull/394
  
    > Does the last change help you?
    
    No. Actually, the problem isn't connected with this task any more, the editor has changed as a result of the сommit fc4781d which is linked to [bug 61625], at first sight absolutely not relating to it
    
    [bug 61625]: https://netbeans.org/bugzilla/show_bug.cgi?id=61625


---