jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1833873 - in /jmeter/trunk: src/core/org/apache/jmeter/save/SaveService.java xdocs/changes.xml
Date Tue, 19 Jun 2018 20:20:16 GMT
Author: pmouawad
Date: Tue Jun 19 20:20:15 2018
New Revision: 1833873

URL: http://svn.apache.org/viewvc?rev=1833873&view=rev
Log:
Bug 62473 - Setting "saveservice_properties" has counter intuitive behaviour
Bugzilla Id: 62473

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java?rev=1833873&r1=1833872&r2=1833873&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java Tue Jun 19 20:20:15 2018
@@ -123,11 +123,11 @@ public class SaveService {
     private static final String XML_HEADER = "<?xml version=\"1.0\" encoding=\"<ph>\"?>";
// $NON-NLS-1$
 
     // Default file name
-    private static final String SAVESERVICE_PROPERTIES_FILE = "/bin/saveservice.properties";
// $NON-NLS-1$
+    private static final String SAVESERVICE_PROPERTIES_FILE = "saveservice.properties"; //
$NON-NLS-1$
 
     // Property name used to define file name
     private static final String SAVESERVICE_PROPERTIES = "saveservice_properties"; // $NON-NLS-1$
-
+    
     // Define file format versions
     private static final String VERSION_2_2 = "2.2";  // $NON-NLS-1$
 
@@ -182,11 +182,21 @@ public class SaveService {
         }
     }
 
+    private static File getSaveServiceFile() {
+        String saveServiceProps = JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES,SAVESERVICE_PROPERTIES_FILE);
//$NON-NLS-1$
+        if (saveServiceProps.length() > 0){ //$NON-NLS-1$
+            return JMeterUtils.findFile(saveServiceProps);
+        }
+        throw new IllegalStateException("Could not find file configured in saveservice_properties
property set to:"+saveServiceProps);
+    }
+    
     public static Properties loadProperties() throws IOException{
         Properties nameMap = new Properties();
-        try (FileInputStream fis = new FileInputStream(JMeterUtils.getJMeterHome()
-                + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES, SAVESERVICE_PROPERTIES_FILE))){
-            nameMap.load(fis);
+        File saveServiceFile = getSaveServiceFile();
+        if (saveServiceFile.canRead()){
+            try (FileInputStream fis = new FileInputStream(saveServiceFile)){
+                nameMap.load(fis);
+            }
         }
         return nameMap;
     }
@@ -194,10 +204,9 @@ public class SaveService {
     private static String getChecksumForPropertiesFile()
             throws NoSuchAlgorithmException, IOException {
         MessageDigest md = MessageDigest.getInstance("SHA1");
+        File saveServiceFile = getSaveServiceFile();
         try (BufferedReader reader = 
-                Files.newBufferedReader(new File(JMeterUtils.getJMeterHome()
-                    + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES,
-                    SAVESERVICE_PROPERTIES_FILE)).toPath(), Charset.defaultCharset())) {
+                Files.newBufferedReader(saveServiceFile.toPath(), Charset.defaultCharset()))
{
             String line = null;
             while ((line = reader.readLine()) != null) {
                 md.update(line.getBytes());

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1833873&r1=1833872&r2=1833873&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml [utf-8] (original)
+++ jmeter/trunk/xdocs/changes.xml [utf-8] Tue Jun 19 20:20:15 2018
@@ -143,6 +143,7 @@ this behaviour, set <code>httpclient.res
   <li><bug>62238</bug>Add ability to Switch to next iteration of Current
Loop. Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
   <li><bug>62239</bug>Add ability to Break Current Loop</li>
   <li><bug>62470</bug>CSV Output : Enable logging of sub results when <code>jmeter.save.saveservice.subresults=true</code>.
Contributed by Ubik Load Pack (support at ubikloadpack.com)</li>
+  <li><bug>62473</bug>Setting "saveservice_properties" has counter intuitive
behaviour</li>
   <li><bug>62065</bug>Use Maven artifact for JAF Module instead of embedded
module</li>
   <li><pr>379</pr> Improve chinese translations. Contributed by XmeterNet</li>
   <li><bug>61714</bug>Update Real-time results documentation</li>



Mime
View raw message