apache / apache/jmeter

Bug: com.ctc.wstx.exc.WstxIOException: Invalid white space character or com.ctc.wstx.exc.WstxIOException: Invalid null character in text to output for request contain binary data

Open
#6,761 0 comments 0 reactions 0 assignees View on GitHub
block-release defect regression
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

### Expected behavior

Since the move of xmlpull to Woodstox, test element or sample result with value contains "binary data" generate Exception Invalid white space/null character

in attachments with JMeter snapshots:
- jmeter-6.0.0-snapshot-bug.log with the full error messages (recording + saving)
- test script with recording setup: 01-recording-test-6_0_0.jmx

Attachement with JMeter 5.6.3:

- jmx script with binary data from mozilla: 01-recording-test-5_6_3.jmx
- record session : debug-recording-5_6_3-01.xml (jtl)
- jmeter-5.6.3.log with Warnings about binary data (not relevant for this issue).

```
WARN o.a.j.p.h.v.RequestViewHTTP: Error decoding query, maybe your request parameters should be encoded: XXXXXXXXXXXXXXXXXXXXXXX
java.lang.IllegalArgumentException: URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 0 in: "YR"
```

### Actual behavior

In two ways:
1. Recording (and writing a .jtl result) with HTTP Test Script Recorder or a listener that writes records request to file.
2. Try to save the .jmx test plan

With JMeter 6.0.0-SNAPSHOT
=> Probably related to this commit "chore: replace xmlpull with Woodstox" https://github.com/apache/jmeter/commit/920fa60dc2ebd1d8644fc9c09478ca757c9931dc
=> From manual: https://jmeter.apache.org/usermanual/component_reference.html#listeners

> XML files written by JMeter have version 1.0 declared in header while actual file is serialized with 1.1 rules. (see bug 59973 #4056 and 58679 #3708) This causes strict XML parsers to fail. Consider using non-strict XML parsers to read JTL files.

=> Woodstox is a strict XML parser I think

* 1/ Recording a sample:

```
ERROR o.a.j.r.ResultCollector: Error trying to record a sample
java.lang.IllegalArgumentException: Failed marshalling:class:class org.apache.jmeter.protocol.http.sampler.HTTPSampleResult,content:016 - /submit/firefox-desktop/newtab/1/15
0d5ef2-9e19-418e-b22b-a282db11e7fa ()
at org.apache.jmeter.save.SaveService.saveSampleResult(SaveService.java:355)
[...]
Caused by: com.thoughtworks.xstream.io.StreamException:
at com.thoughtworks.xstream.io.xml.StaxWriter.setValue(StaxWriter.java:160)
at org.apache.jmeter.save.converters.SampleResultConverter.writeString(SampleResultConverter.java:360)
... 4 more
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid white space character (0x1f) in text to output (in xml 1.1, could output as a character entity)
at com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:469)
at com.sun.xml.txw2.output.DelegatingXMLStreamWriter.writeCharacters(DelegatingXMLStreamWriter.java:151)
at com.sun.xml.txw2.output.IndentingXMLStreamWriter.writeCharacters(IndentingXMLStreamWriter.java:181)
at org.apache.jmeter.save.XMLStreamWriterSkipHeader.writeCharacters(XMLStreamWriterSkipHeader.kt)
at com.thoughtworks.xstream.io.xml.StaxWriter.setValue(StaxWriter.java:158)
... 14 more
Caused by: java.io.IOException: Invalid white space character (0x1f) in text to output (in xml 1.1, could output as a character entity)
at com.ctc.wstx.api.InvalidCharHandler$FailingHandler.convertInvalidChar(InvalidCharHandler.java:56)
```

* 2/ Saving a JMX plan:

```
ERROR o.a.j.g.a.ActionRouter: Error processing org.apache.jmeter.gui.action.Save@c0b4edf
com.thoughtworks.xstream.io.StreamException:
at com.thoughtworks.xstream.io.xml.StaxWriter.setValue(StaxWriter.java:160)

[01-recording-test-5_6_3.jmx.xml](https://github.com/user-attachments/files/31680230/01-recording-test-5_6_3.jmx.xml)
[debug-recording-5_6_3-01.xml](https://github.com/user-attachments/files/31680231/debug-recording-5_6_3-01.xml)

at com.thoughtworks.xstream.io.WriterWrapper.setValue(WriterWrapper.java:45)
at org.apache.jmeter.save.converters.StringPropertyConverter.marshal(StringPropertyConverter.java:53)
[...]
Caused by: com.ctc.wstx.exc.WstxIOException: Invalid null character in text to output
at com.ctc.wstx.sw.BaseStreamWriter.writeCharacters(BaseStreamWriter.java:469)
[...]
Caused by: java.io.IOException: Invalid null character in text to output
at com.ctc.wstx.api.InvalidCharHandler$FailingHandler.convertInvalidChar(InvalidCharHandler.java:52)

```

### Steps to reproduce the problem

To Reproduce:

[jmeter-6.0.0-snapshot-bug.log](https://github.com/user-attachments/files/31680161/jmeter-6.0.0-snapshot-bug.log)

[01-recording-test-6_0_0.jmx.xml](https://github.com/user-attachments/files/31680174/01-recording-test-6_0_0.jmx.xml)

1- Prepare a Firefox (last version) with with Proxy set to JMeter HTTP Test Script Recorder, and stop Firefox
2- Open the example file .jmx, start the HTTP Test Script Recorder.
2- Start firefox (last version), and see the jmeter.log about the incoming.telemetry.mozilla.org requests

For example :
```
Host: incoming.telemetry.mozilla.org
Path: /submit/firefox-desktop/events/1/97647d0d-fbe5-49ba-ab9c-fb321bb204db
Body data:
```

### JMeter Version

6.0.0

### Java Version

java version "17.0.14" 2025-01-21 LTS Java(TM) SE Runtime Environment (build 17.0.14+8-LTS-191) Java HotSpot(TM) 64-Bit Server VM (build 17.0.14+8-LTS-191, mixed mode, sharing)

### OS Version

Debian GNU/Linux 13 (trixie)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with 01-recording-test-6_0_0.jmx.xml and the supplied Firefox request data. Trace the recording path through SaveService.saveSampleResult, SampleResultConverter.writeString, XMLStreamWriterSkipHeader, and the JMX path through StringPropertyConverter and StaxWriter. Done means binary or control-character request data no longer prevents sample recording or JMX plan saving.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.