GitHub user ham1 opened a pull request:
https://github.com/apache/jmeter/pull/346
Bug 61827 - TextFile always adds newline to end of string
## Description
Re-wrote `getText` (and `setText` while I was there) for `TextFile` because
`getText` always appends a newline separator at the end of the file regardless
if the original file has one or not.
This changes the behaviour slightly and currently breaks some tests. I'm
not sure if it's the tests' fault or the change. I've "fixed" the tests, but
these need reviewing by someone who knows how the JMS stuff and anything else
which uses it works and any assumptions they made.
## Motivation and Context
https://bz.apache.org/bugzilla/show_bug.cgi?id=61827
> a new line is adding to the content of the file read by a JMS publisher
sampler.
The issue is on the getText method of the TextFile :
=> sb.append(line + lineEnd);
## How Has This Been Tested?
Added unit tests to demo the new behaviour, previous could would have
failed by added an extra newline to end of file which did not end in a new line.
## Screenshots (if appropriate):
## Types of changes
- Bug fix (non-breaking change which fixes an issue)
- New feature (non-breaking change which adds functionality)
- Breaking change (fix or feature that would cause existing functionality
to not work as expected)
## Checklist:
- [ ] 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/ham1/jmeter bug_61827
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/jmeter/pull/346.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 #346
commit 944170a6aaf6b416e93cd1f0008460858351cd78
Author: Graham Russell
Date: 2017-11-30T17:47:50Z
Re-wrote getText() method
commit d793c2e18ac32bc9cd7e5805b83750954d74218d
Author: Graham Russell
Date: 2017-11-30T19:21:00Z
Fixed read and write and added tests
commit a52fec86f2b4b0ab966e478ac466c63d695494ff
Author: Graham Russell
Date: 2017-11-30T19:21:58Z
PublisherSampler.java tweaks
commit 0b90d513301e6e498645e4c3d88dce62291e9f41
Author: Graham Russell
Date: 2017-12-01T00:07:35Z
Updated unit tests
commit 16d01091b5655096f285977fbfa296d9d9b45bc7
Author: Graham Russell
Date: 2017-12-01T00:16:53Z
Improve code
commit 8196a066769db7ced7cf32bdc4abf6a3a46c7027
Author: Graham Russell
Date: 2017-12-01T01:39:05Z
Fix other tests
---