JMeter处理大JSON文件报错求助:URLDecoder非法转义字符问题
JMeter处理大JSON文件报错问题
问题场景
处理约5.5万行的大JSON输入时,使用__FileToString函数读取文件内容后触发解析错误,该请求在Postman中可正常运行。
使用的函数
${__FileToString(myPath/test.json,,)}
错误日志
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - For input string: "1[" at java.net.URLDecoder.decode(Unknown Source) ~[?:1.8.0_301] at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.decodeQuery(RequestViewHTTP.java:336) ~[ApacheJMeter_http.jar:5.5] at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.getQueryMap(RequestViewHTTP.java:306) ~[ApacheJMeter_http.jar:5.5] at org.apache.jmeter.protocol.http.visualizers.RequestViewHTTP.setSamplerResult(RequestViewHTTP.java:216) ~[ApacheJMeter_http.jar:5.5] at org.apache.jmeter.visualizers.RequestPanel.setSamplerResult(RequestPanel.java:116) ~[ApacheJMeter_components.jar:5.5] at org.apache.jmeter.visualizers.SamplerResultTab.setupTabPane(SamplerResultTab.java:256) ~[ApacheJMeter_components.jar:5.5] at org.apache.jmeter.visualizers.ViewResultsFullVisualizer.valueChanged(ViewResultsFullVisualizer.java:395) ~[ApacheJMeter_components.jar:5.5] at org.apache.jmeter.visualizers.ViewResultsFullVisualizer.valueChanged(ViewResultsFullVisualizer.java:373) ~[ApacheJMeter_components.jar:5.5] at javax.swing.JTree.fireValueChanged(Unknown Source) ~[?:1.8.0_301] at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source) ~[?:1.8.0_301] at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source) ~[?:1.8.0_301] at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source) ~[?:1.8.0_301] at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source) ~[?:1.8.0_301] at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source) ~[?:1.8.0_301] at javax.swing.JTree.setSelectionPath(Unknown Source) ~[?:1.8.0_301] at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source) ~[?:1.8.0_301] at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source) ~[?:1.8.0_301] at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source) ~[?:1.8.0_301] at java.awt.AWTEventMulticaster.mousePressed(Unknown Source) ~[?:1.8.0_301] at java.awt.Component.processMouseEvent(Unknown Source) ~[?:1.8.0_301] at javax.swing.JComponent.processMouseEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.Component.processEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.Container.processEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.Component.dispatchEventImpl(Unknown Source) ~[?:1.8.0_301] at java.awt.Container.dispatchEventImpl(Unknown Source) ~[?:1.8.0_301] at java.awt.Component.dispatchEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.Container.dispatchEventImpl(Unknown Source) ~[?:1.8.0_301] at java.awt.Window.dispatchEventImpl(Unknown Source) ~[?:1.8.0_301] at java.awt.Component.dispatchEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue.dispatchEventImpl(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue.access$500(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue$3.run(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue$3.run(Unknown Source) ~[?:1.8.0_301] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_301] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) ~[?:1.8.0_301] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue$4.run(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue$4.run(Unknown Source) ~[?:1.8.0_301] at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_301] at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) ~[?:1.8.0_301] at java.awt.EventQueue.dispatchEvent(Unknown Source) ~[?:1.8.0_301] at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) ~[?:1.8.0_301] at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) ~[?:1.8.0_301] at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) ~[?:1.8.0_301] at java.awt.EventDispatchThread.pumpEvents(Unknown Source) ~[?:1.8.0_301] at java.awt.EventDispatchThread.pumpEvents(Unknown Source) ~[?:1.8.0_301] at java.awt.EventDispatchThread.run(Unknown Source) ~[?:1.8.0_301]
解决方法
- 关闭查看结果树组件后再运行测试:该错误是JMeter的UI解析组件触发的,并非请求本身执行失败,关闭UI组件后可正常发送请求。
- 改用CSV Data Set Config读取文件:配置
Filename为myPath/test.json,Variable Names设为payload,Delimiter留空,勾选Allow quoted data,请求体中直接引用${payload}即可。 - 对JSON内容做URL编码:如果坚持用
__FileToString,可嵌套编码函数:${__urlencode(${__FileToString(myPath/test.json,,)})},注意确认服务器是否支持解码后的内容。 - 升级JMeter版本:JMeter 5.5存在大内容解析的UI组件bug,升级到5.6.x及以上版本可修复该问题。
内容的提问来源于stack exchange,提问作者BlueCode_xxx
相关产品推荐
相关产品推荐

