Bug 60822 - ResultCollector does not ensure unique file name entries in files HashMap
Summary: ResultCollector does not ensure unique file name entries in files HashMap
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: Main (show other bugs)
Version: 3.1
Hardware: PC Mac OS X 10.1
: P2 normal (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-05 19:52 UTC by Sebb
Modified: 2017-03-08 15:44 UTC (History)
0 users



Attachments
Test showing problem (14.28 KB, application/xml)
2017-03-06 15:13 UTC, Sebb
Details
output XML file showing mixed output (1.94 KB, text/plain)
2017-03-06 15:15 UTC, Sebb
Details
Test showing problem for CSV (14.29 KB, text/plain)
2017-03-06 15:23 UTC, Sebb
Details
output CSV file showing truncated output (1.34 KB, text/plain)
2017-03-06 15:24 UTC, Sebb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebb 2017-03-05 19:52:10 UTC
ResultCollector tries to ensure that multiple references to the same file in a Test Plan only generate a single Writer.

However, it does not canonicalise the file names, so the same physical file may be written by two Writers.

For example, test.jtl and ./test.jtl will result in separate entries in the files HashMap. This could be fixed by using File.getCanonicalPath()

Also test.jtl and Test.jtl currently generate separate entries even on case-insensitive file systems. 

There does not seem to be a way to detect file system case-sensitivity in Java.

Path.toRealPath() produces unique names for case-insenstive systems but only works for existing files, so would require the file to be exist first. That might be acceptable here, because the purpose of the ResultCollector is to write the file. File.toCanonicalPath() does not take account of case sensitivity.

It looks as though File.getCanonicalPath() returns the file name with its actual case if the file exists.

Note that case-sensitivity is a property of the file system, not the OS, so the same host could potentially have multiple file systems with different case-sensitivity
Comment 1 Sebb 2017-03-06 15:13:52 UTC
Created attachment 34801 [details]
Test showing problem
Comment 2 Sebb 2017-03-06 15:15:11 UTC
Created attachment 34802 [details]
output XML file showing mixed output
Comment 3 Sebb 2017-03-06 15:23:41 UTC
Created attachment 34803 [details]
Test showing problem for CSV
Comment 4 Sebb 2017-03-06 15:24:19 UTC
Created attachment 34804 [details]
output CSV file showing truncated output
Comment 5 Sebb 2017-03-08 15:44:27 UTC
Note: as it happens the first call to initializeFileOutput() creates the file if it does not exist, so File.getCanonicalPath() is sufficient to ensure uniqueness.

Also added some debug logging to show when file is created/initialised.

URL: http://svn.apache.org/viewvc?rev=1785990&view=rev
Log:
ResultCollector does not ensure unique file name entries in files HashMap
Bugzilla Id: 60822

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/reporters/ResultCollector.java
    jmeter/trunk/xdocs/changes.xml
Comment 6 The ASF infrastructure team 2022-09-24 20:38:08 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/4320