sebb 2005/09/06 15:08:20
Modified: src/protocol/http/org/apache/jmeter/protocol/http/sampler
Tag: rel-2-1 WebServiceSampler.java
Log:
Bug 36500 - handle missing data more gracefully
Revision Changes Path
No revision
No revision
1.28.2.1 +23 -12
jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java
Index: WebServiceSampler.java
===================================================================
RCS file:
/home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/WebServiceSampler.java,v
retrieving revision 1.28
retrieving revision 1.28.2.1
diff -u -r1.28 -r1.28.2.1
--- WebServiceSampler.java 12 Jul 2005 20:50:56 -0000 1.28
+++ WebServiceSampler.java 6 Sep 2005 22:08:20 -0000 1.28.2.1
@@ -21,6 +21,7 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
@@ -33,6 +34,7 @@
import javax.xml.parsers.DocumentBuilder;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import org.apache.jorphan.io.TextFile;
import org.apache.jorphan.logging.LoggingManager;
@@ -371,7 +373,8 @@
if (DOMPool.getDocument(next) != null) {
return
DOMPool.getDocument(next).getDocumentElement();
} else {
- return openDocument(next).getDocumentElement();
+ Document doc = openDocument(next);
+ return doc == null ? null :
doc.getDocumentElement();
}
} else {
Document doc = openDocument(null);
@@ -400,21 +403,29 @@
if (getXmlFile().length() > 0 || getXmlPathLoc().length() > 0) {
try {
doc = XDB.parse(new
FileInputStream(retrieveRuntimeXmlData()));
- } catch (Exception e) {
- // there should be a file, if not fail silently
- log.debug(e.getMessage());
- }
+ } catch (SAXException e) {
+ log.warn("Error processing file data:
"+e.getMessage());
+ } catch (FileNotFoundException e) {
+ log.warn(e.getMessage());
+ } catch (IOException e) {
+ log.warn(e.getMessage());
+ }
} else {
FILE_CONTENTS = getXmlData();
if (FILE_CONTENTS != null && FILE_CONTENTS.length() >
0) {
try {
doc = XDB.parse(new InputSource(new
StringReader(FILE_CONTENTS)));
- } catch (Exception ex) {
- log.debug(ex.getMessage());
- }
- }
+ } catch (SAXException ex) {
+ log.warn("Error processing data:
"+ex.getMessage());
+ } catch (IOException ex) {
+ log.warn(ex.getMessage()); // shouldn't really happen
+ }
+ } else {
+ log.warn("No post data provided!");
+ }
}
- if (this.getPropertyAsBoolean(MEMORY_CACHE)) {
+ // don't cache null documents ...
+ if (doc != null && this.getPropertyAsBoolean(MEMORY_CACHE)) {
DOMPool.putDocument(key, doc);
}
return doc;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]