Bug 65884 - GUI doesn't display response for multipart request "manually" encoded
Summary: GUI doesn't display response for multipart request "manually" encoded
Status: RESOLVED FIXED
Alias: None
Product: JMeter
Classification: Unclassified
Component: HTTP (show other bugs)
Version: unspecified
Hardware: PC All
: P2 major (vote)
Target Milestone: JMETER_5.5
Assignee: JMeter issues mailing list
URL:
Keywords: FixedInTrunk
Depends on:
Blocks:
 
Reported: 2022-02-15 10:39 UTC by Marc Stern
Modified: 2022-02-21 15:46 UTC (History)
0 users



Attachments
Minimal testplan to show the exception (6.22 KB, application/xml)
2022-02-16 16:53 UTC, Felix Schumacher
Details
Allow unquoted tokens for values in content disposition header (3.43 KB, patch)
2022-02-16 20:59 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Stern 2022-02-15 10:39:17 UTC
When sending a multipart request without ticking the "Use multipart/form-data" box and filling the Content-Type manually (because I need to test the server with that specific request), the GUI generates an exception when trying to see the response and doesn't display it.
Same problem with HTTP4Client and Java.
Same problem with a valid and invalid request.

Example:
HTTP Request:
POST
HTTP Header Manager:
Content-Type: multipart/form-data; boundary=da0bad6c-05aa-4901-81d5-1f1da00a1d42
Body Data:
--da0bad6c-05aa-4901-81d5-1f1da00a1d42
Content-Type: application/pdf
Content-Disposition: form-data; name=file; filename=test.pdf

%PDF-1.4
%%EOF

--da0bad6c-05aa-4901-81d5-1f1da00a1d42--

The request is sent, the response is sent back.
In the GUI, the request is displayed normally, the response body & headers is empty.
In the log console, we have an exception:
ERROR o.a.j.JMeter: Uncaught exception in thread Thread[AWT-EventQueue-0,6,main]
java.lang.StringIndexOutOfBoundsException: begin 5, end -1, length 39
	at java.lang.String.checkBoundsBeginEnd(String.java:3756) ~[?:?]
	at java.lang.String.substring(String.java:1902) ~[?:?]
	at org.apache.jmeter.protocol.http.config.MultipartUrlConfig.parseArguments(MultipartUrlConfig.java:134) ~[ApacheJMeter_http.jar:5.4.2]
	at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.setSamplerResult(RequestViewHTTP.java:228) ~[ApacheJMeter_http.jar:5.4.2]
	at org.apache.jmeter.visualizers.RequestPanel.setSamplerResult(RequestPanel.java:116) ~[ApacheJMeter_components.jar:5.4.2]
	at org.apache.jmeter.visualizers.SamplerResultTab.setupTabPane(SamplerResultTab.java:238) ~[ApacheJMeter_components.jar:5.4.2]
[...]
Comment 1 Felix Schumacher 2022-02-16 16:53:12 UTC
Created attachment 38196 [details]
Minimal testplan to show the exception

Load the test plan, start the mirror server, run the plan, look at the result view tree. There should be an exception in the log file.
Comment 2 Felix Schumacher 2022-02-16 20:59:59 UTC
Created attachment 38197 [details]
Allow unquoted tokens for values in content disposition header

The exceptions comes from our headers parser. It expects quotes around the values for the content-disposition element fields.

If you change the header from

content-disposition: form-data; name=file; filename=test.pdf

to

content-disposition: form-data; name="file"; filename="test.pdf"

it will display the sample results without problem.

Attached is a fix for this, that replaces our homegrown parser with one from the httpcomponents project, which has no trouble to parse either of the lines.
Comment 3 Marc Stern 2022-02-17 07:15:05 UTC
Thanks for the patch.
Unfortunately, I cannot compile JMeter myself.
Any chance to have this in a nightly build to test it (if it's publicly available)?
In the mean time, I'll test with the quotes, altough I also need some requests without quotes.
Comment 4 Marc Stern 2022-02-17 07:27:50 UTC
As an additional note, it would be very interesting to have an option to not parse at all requests (and/or responses), thus having only the "Raw" tabs(s).
This would allow testing incorrect requests/responses, which is quitecommon when you develop a server (negative tests) or, like me, Web Application Firewall rules.
This would be on top of your patch, which is a very good measure, as these options would be more generic.
Should I open a new ticket (enhrancement request) for this?
Comment 5 Felix Schumacher 2022-02-17 19:59:15 UTC
commit 33ad9306b2fbe823fd9fd1bd207262cd7a0ec4a6
AuthorDate: Wed Feb 16 21:54:44 2022 +0100

    Allow unquoted tokens for values in content-disposition header
    
    Use httpcomponents BasicHeaderValueParser instead of our simple parser, as
    we were assuming parameters would always be surrounded by quotes.
    
    Bugzilla Id: 65884
---
 .../protocol/http/config/MultipartUrlConfig.java   | 47 +++++++++----
 .../http/config/MultipartUrlConfigTest.java        | 82 +++++++++++++++++++++-
 xdocs/changes.xml                                  |  1 +
 3 files changed, 114 insertions(+), 16 deletions(-)
Comment 6 Felix Schumacher 2022-02-17 20:01:49 UTC
@Marc, could you test next nightly and report back, whether it fixes your use case?

For "not parsing the request on failure"-mode, please open a new issue. Note, that you might get away by switching to "regex"-mode, as that does not parse the body already. (I know it is a workaround)
Comment 7 Felix Schumacher 2022-02-17 20:22:10 UTC
commit bc0d31de7b06b4b2666637e8fdcee74548e3e79f
AuthorDate: Thu Feb 17 21:19:14 2022 +0100

    Fix generated Content-disposition header for failing test
    
    After fixing issue 65884, the parser for the content-disposition header is more
    lenient on the usage of quotes, but less forgiving about missing seperators between
    the parameters.
    
    Part of Bugzilla Id: 65884
---
 .../java/org/apache/jmeter/protocol/http/proxy/TestHttpRequestHdr.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 8 Marc Stern 2022-02-18 09:40:10 UTC
(In reply to Felix Schumacher from comment #6)
> @Marc, could you test next nightly and report back, whether it fixes your
> use case?
It cannot load my jmx:
2022-02-18 10:36:51,057 ERROR o.a.j.g.u.JSyntaxTextArea: Dubious problem while setting text to System.gc();
java.lang.NullPointerException: null
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.updateMetrics(WrappedSyntaxView.java:1081) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.getPreferredSpan(WrappedSyntaxView.java:618) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.calculateBreakPosition(WrappedSyntaxView.java:114) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView$WrappedLine.calculateLineCount(WrappedSyntaxView.java:1191) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView$WrappedLine.handleDocumentEvent(WrappedSyntaxView.java:1440) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView$WrappedLine.insertUpdate(WrappedSyntaxView.java:1464) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.insertUpdate(WrappedSyntaxView.java:705) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:1706) ~[?:?]
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.java:1965) ~[?:?]
	at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:203) ~[?:?]
	at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.fireInsertUpdate(RSyntaxDocument.java:187) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:757) ~[?:?]
	at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:716) ~[?:?]
	at javax.swing.text.PlainDocument.insertString(PlainDocument.java:131) ~[?:?]
	at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:675) ~[?:?]
	at javax.swing.text.JTextComponent.setText(JTextComponent.java:1729) ~[?:?]
	at org.apache.jmeter.gui.util.JSyntaxTextArea.setInitialText(JSyntaxTextArea.java:296) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.testbeans.gui.TextAreaEditor.setValue(TextAreaEditor.java:112) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.setEditorValue(GenericTestBeanCustomizer.java:479) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.setObject(GenericTestBeanCustomizer.java:511) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.testbeans.gui.TestBeanGUI.setValues(TestBeanGUI.java:323) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.testbeans.gui.TestBeanGUI.configure(TestBeanGUI.java:307) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.tree.JMeterTreeModel.addComponent(JMeterTreeModel.java:162) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:131) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:123) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.GuiPackage.addSubTree(GuiPackage.java:554) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:199) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:235) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.JMeter.startGui(JMeter.java:431) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.JMeter.start(JMeter.java:566) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at org.apache.jmeter.NewDriver.main(NewDriver.java:257) [ApacheJMeter.jar:5.5-SNAPSHOT]
2022-02-18 10:36:51,095 WARN o.j.r.PluginManagerMenuItem: Failed to load plugin updates info
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
	at net.sf.json.JSONObject.<init>(JSONObject.java:1450) ~[json-lib-2.4-jdk15.jar:?]
	at net.sf.json.util.CycleDetectionStrategy.<clinit>(CycleDetectionStrategy.java:37) ~[json-lib-2.4-jdk15.jar:?]
	at net.sf.json.JsonConfig.<clinit>(JsonConfig.java:65) ~[json-lib-2.4-jdk15.jar:?]
	at org.jmeterplugins.repository.JARSourceHTTP.getRepositories(JARSourceHTTP.java:274) ~[jmeter-plugins-manager-1.7.jar:?]
	at org.jmeterplugins.repository.JARSourceHTTP.getRepo(JARSourceHTTP.java:304) ~[jmeter-plugins-manager-1.7.jar:?]
	at org.jmeterplugins.repository.PluginManager.load(PluginManager.java:71) ~[jmeter-plugins-manager-1.7.jar:?]
	at org.jmeterplugins.repository.PluginManagerMenuItem$1.run(PluginManagerMenuItem.java:38) [jmeter-plugins-manager-1.7.jar:?]
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections.map.ListOrderedMap
	at java.net.URLClassLoader.findClass(URLClassLoader.java:435) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:589) ~[?:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[?:?]
	... 7 more
2022-02-18 10:36:51,097 ERROR o.a.j.JMeter: Failure loading test file
java.lang.NullPointerException: null
	at org.fife.ui.rsyntaxtextarea.TokenImpl.getWidthUpTo(TokenImpl.java:578) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.TokenImpl.getWidth(TokenImpl.java:570) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.calculateBreakPosition(WrappedSyntaxView.java:127) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView$WrappedLine.calculateLineCount(WrappedSyntaxView.java:1191) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView$WrappedLine.handleDocumentEvent(WrappedSyntaxView.java:1440) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView$WrappedLine.insertUpdate(WrappedSyntaxView.java:1464) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at org.fife.ui.rsyntaxtextarea.WrappedSyntaxView.insertUpdate(WrappedSyntaxView.java:705) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at javax.swing.plaf.basic.BasicTextUI$RootView.insertUpdate(BasicTextUI.java:1706) ~[?:?]
	at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.insertUpdate(BasicTextUI.java:1965) ~[?:?]
	at javax.swing.text.AbstractDocument.fireInsertUpdate(AbstractDocument.java:203) ~[?:?]
	at org.fife.ui.rsyntaxtextarea.RSyntaxDocument.fireInsertUpdate(RSyntaxDocument.java:187) ~[rsyntaxtextarea-3.1.3.jar:3.1.3]
	at javax.swing.text.AbstractDocument.handleInsertString(AbstractDocument.java:757) ~[?:?]
	at javax.swing.text.AbstractDocument.insertString(AbstractDocument.java:716) ~[?:?]
	at javax.swing.text.PlainDocument.insertString(PlainDocument.java:131) ~[?:?]
	at javax.swing.text.AbstractDocument.replace(AbstractDocument.java:675) ~[?:?]
	at javax.swing.text.JTextComponent.setText(JTextComponent.java:1729) ~[?:?]
	at org.apache.jmeter.assertions.gui.AssertionGui.configure(AssertionGui.java:256) ~[ApacheJMeter_components.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.tree.JMeterTreeModel.addComponent(JMeterTreeModel.java:162) ~[ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:131) ~[ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.tree.JMeterTreeModel.addSubTree(JMeterTreeModel.java:123) ~[ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.GuiPackage.addSubTree(GuiPackage.java:554) ~[ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:199) ~[ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.gui.action.Load.insertLoadedTree(Load.java:235) ~[ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.JMeter.startGui(JMeter.java:431) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at org.apache.jmeter.JMeter.start(JMeter.java:566) [ApacheJMeter_core.jar:5.5-SNAPSHOT]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:564) ~[?:?]
	at org.apache.jmeter.NewDriver.main(NewDriver.java:257) [ApacheJMeter.jar:5.5-SNAPSHOT]
2022-02-18 10:36:51,098 ERROR o.a.j.u.JMeterUtils: java.lang.NullPointerException
Comment 9 Felix Schumacher 2022-02-18 11:32:31 UTC
I believe, that the NPE is a result from fixing Bug 63620 and can (at least on my machine) be ignored. It should not interfere any further.

The ClassNotFoundException should be unrelated to this (nor 63620) and might be a conflicting or missing commons-collections (3 or 4) jar. Look for commons-collections*.jar in the lib folder (and its subfolders), are there duplicate entries? You should find commons-collections-3.2.2.jar and commons-collections4-4.4.jar directly under lib.

Which OS and JDK are you testing with?

If you are willing to try, I can provide you with a JMeter version without the fixes for 63620.
Comment 10 Felix Schumacher 2022-02-19 18:53:40 UTC
I hope, that I have fixed the NPE that resulted from fixing Bug 63620, so please try a new nightly (if you fixed the other exception or use the minimal test plan :) )
Comment 11 Marc Stern 2022-02-21 15:42:46 UTC
I tested latest build and no more exception. Thanks!
Comment 12 Felix Schumacher 2022-02-21 15:46:42 UTC
Thanks for the confirmation