You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by se...@apache.org on 2015/02/11 21:06:42 UTC
svn commit: r1659056 - in /jmeter/trunk:
src/core/org/apache/jmeter/services/FileServer.java
test/src/org/apache/jmeter/services/TestFileServer.java xdocs/changes.xml
Author: sebb
Date: Wed Feb 11 20:06:41 2015
New Revision: 1659056
URL: http://svn.apache.org/r1659056
Log:
FileServer.reserveFile - inconsistent behaviour when hasHeader is true
Bugzilla Id: 57569
Modified:
jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java
jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java?rev=1659056&r1=1659055&r2=1659056&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/services/FileServer.java Wed Feb 11 20:06:41 2015
@@ -24,6 +24,7 @@ package org.apache.jmeter.services;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
+import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -279,10 +280,17 @@ public class FileServer {
try {
fileEntry.headerLine=readLine(alias, false);
} catch (IOException e) {
+ fileEntry.exception = e;
throw new IllegalArgumentException("Could not read file header line",e);
}
+ if (fileEntry.headerLine == null) {
+ fileEntry.exception = new EOFException("File is empty: " + fileEntry.file);
+ }
}
}
+ if (hasHeader && fileEntry.headerLine == null) {
+ throw new IllegalArgumentException("Could not read file header line", fileEntry.exception);
+ }
return fileEntry.headerLine;
}
@@ -500,6 +508,7 @@ public class FileServer {
private static class FileEntry{
private String headerLine;
+ private Throwable exception;
private final File file;
private Closeable inputOutputObject;
private final String charSetEncoding;
Modified: jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java?rev=1659056&r1=1659055&r2=1659056&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/services/TestFileServer.java Wed Feb 11 20:06:41 2015
@@ -116,4 +116,44 @@ public class TestFileServer extends JMet
FS.setBaseForScript(file);
assertEquals("abcd",FS.getBaseDirRelative().toString());
}
+
+ public void testHeaderMissingFile() throws Exception {
+ final String missing = "no-such-file";
+ final String alias = "missing";
+ final String charsetName = "UTF-8";
+
+ try {
+ FS.reserveFile(missing,charsetName,alias,true);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertTrue("Expected FNF", e.getCause() instanceof java.io.FileNotFoundException);
+ }
+ // Ensure second invocation gets same behaviour
+ try {
+ FS.reserveFile(missing,charsetName,alias,true);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertTrue("Expected FNF", e.getCause() instanceof java.io.FileNotFoundException);
+ }
+ }
+
+ public void testHeaderEmptyFile() throws Exception {
+ final String empty = findTestPath("testfiles/empty.csv");
+ final String alias = "empty";
+ final String charsetName = "UTF-8";
+
+ try {
+ String hdr= FS.reserveFile(empty,charsetName,alias,true);
+ fail("Expected IllegalArgumentException|"+hdr+"|");
+ } catch (IllegalArgumentException e) {
+ assertTrue("Expected EOF", e.getCause() instanceof java.io.EOFException);
+ }
+ // Ensure second invocation gets same behaviour
+ try {
+ FS.reserveFile(empty,charsetName,alias,true);
+ fail("Expected IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ assertTrue("Expected EOF", e.getCause() instanceof java.io.EOFException);
+ }
+ }
}
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1659056&r1=1659055&r2=1659056&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Wed Feb 11 20:06:41 2015
@@ -180,6 +180,7 @@ See <bugzilla>56357</bugzilla> for deta
<li><bug>57364</bug>Options < Look And Feel does not update all windows LAF. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
<li><bug>57394</bug>When constructing an instance with ClassTools#construct(String, int) the integer was ignored and the default constructor was used instead.</li>
<li><bug>57440</bug>OutOfMemoryError after introduction of JSyntaxTextArea in LoggerPanel due to disableUndo not being taken into account.</li>
+<li><bug>57569</bug>FileServer.reserveFile - inconsistent behaviour when hasHeader is true</li>
</ul>
<!-- =================== Improvements =================== -->