jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1714452 - in /jmeter/trunk: bin/saveservice.properties src/core/org/apache/jmeter/save/SaveService.java
Date Sun, 15 Nov 2015 13:57:19 GMT
Author: fschumacher
Date: Sun Nov 15 13:57:19 2015
New Revision: 1714452

URL: http://svn.apache.org/viewvc?rev=1714452&view=rev
Log:
Ignore newline character when computing the sha1 sum of saveservice.properties.

Followup to r1714325, since sebb pointed out, that the file could have different
line endings when checked out on different OSes.

Bugzilla Id: 58601

Modified:
    jmeter/trunk/bin/saveservice.properties
    jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java

Modified: jmeter/trunk/bin/saveservice.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/saveservice.properties?rev=1714452&r1=1714451&r2=1714452&view=diff
==============================================================================
--- jmeter/trunk/bin/saveservice.properties (original)
+++ jmeter/trunk/bin/saveservice.properties Sun Nov 15 13:57:19 2015
@@ -37,6 +37,11 @@
 # version number of this file is now computed by a sha1 sum, so no need for
 # an explicit _file_version property anymore.
 #
+# For this sha1 sum we ignore every newline character. It can be computed
+# by the following command:
+#
+# cat bin/saveservice.properties | perl -ne 'chomp; print' | sha1sum
+#
 # Be aware, that every change in this file will change the sha1 sum!
 #
 # Conversion version (for JMX output files)

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=1714452&r1=1714451&r2=1714452&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java Sun Nov 15 13:57:19 2015
@@ -19,6 +19,7 @@
 package org.apache.jmeter.save;
 
 import java.io.BufferedInputStream;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -183,9 +184,9 @@ public class SaveService {
 
     // Internal information only
     private static String fileVersion = ""; // computed from saveservice.properties file//
$NON-NLS-1$
-    // Must match the sha1 checksum of the file saveservice.properties,
+    // Must match the sha1 checksum of the file saveservice.properties (without newline character),
     // used to ensure saveservice.properties and SaveService are updated simultaneously
-    static final String FILEVERSION = "3b98c4294b3ea34dc27d437f32683cf2822892e6"; // Expected
value $NON-NLS-1$
+    static final String FILEVERSION = "3136d9168702a07555b110a86f7ba4da4ab88346"; // Expected
value $NON-NLS-1$
 
     private static String fileEncoding = ""; // read from properties file// $NON-NLS-1$
 
@@ -227,17 +228,22 @@ public class SaveService {
     private static String getChecksumForPropertiesFile()
             throws NoSuchAlgorithmException, IOException {
         FileInputStream fis = null;
+        InputStreamReader inStream = null;
+        BufferedReader reader = null;
         MessageDigest md = MessageDigest.getInstance("SHA1");
         try {
             fis = new FileInputStream(JMeterUtils.getJMeterHome()
                     + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES,
                             SAVESERVICE_PROPERTIES_FILE));
-            byte[] readBuffer = new byte[8192];
-            int bytesRead;
-            while ((bytesRead = fis.read(readBuffer)) != -1) {
-                md.update(readBuffer, 0, bytesRead);
+            inStream = new InputStreamReader(fis);
+            reader = new BufferedReader(inStream);
+            String line = null;
+            while ((line = reader.readLine()) != null) {
+                md.update(line.getBytes());
             }
         } finally {
+            JOrphanUtils.closeQuietly(reader);
+            JOrphanUtils.closeQuietly(inStream);
             JOrphanUtils.closeQuietly(fis);
         }
         return JOrphanUtils.baToHexString(md.digest());



Mime
View raw message