You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2015/11/14 14:48:09 UTC
svn commit: r1714325 - in /jmeter/trunk: bin/saveservice.properties
src/core/org/apache/jmeter/save/SaveService.java xdocs/changes.xml
Author: fschumacher
Date: Sat Nov 14 13:48:09 2015
New Revision: 1714325
URL: http://svn.apache.org/viewvc?rev=1714325&view=rev
Log:
Change check for modifications of saveservice.properties from $Revision to sha1 sum of file.
Bugzilla Id: 58601
Modified:
jmeter/trunk/bin/saveservice.properties
jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java
jmeter/trunk/xdocs/changes.xml
Modified: jmeter/trunk/bin/saveservice.properties
URL: http://svn.apache.org/viewvc/jmeter/trunk/bin/saveservice.properties?rev=1714325&r1=1714324&r2=1714325&view=diff
==============================================================================
--- jmeter/trunk/bin/saveservice.properties (original)
+++ jmeter/trunk/bin/saveservice.properties Sat Nov 14 13:48:09 2015
@@ -34,8 +34,10 @@
# Please keep the entries in alphabetical order within the sections
# to reduce the likelihood of duplicates
#
-# version number of this file (automatically generated by SVN)
-_file_version=$Revision$
+# version number of this file is now computed by a sha1 sum, so no need for
+# an explicit _file_version property anymore.
+#
+# Be aware, that every change in this file will change the sha1 sum!
#
# Conversion version (for JMX output files)
# Must be updated if the file has been changed since the previous release
@@ -381,4 +383,4 @@ _org.apache.jmeter.save.converters.TestR
_org.apache.jmeter.save.ScriptWrapperConverter=mapping
#
# Remember to update the _version entry
-#
\ No newline at end of file
+#
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=1714325&r1=1714324&r2=1714325&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/SaveService.java Sat Nov 14 13:48:09 2015
@@ -29,6 +29,8 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -180,10 +182,10 @@ public class SaveService {
static final String PROPVERSION = "2.9";// Expected version $NON-NLS-1$
// Internal information only
- private static String fileVersion = ""; // read from saveservice.properties file// $NON-NLS-1$
- // Must match Revision id value in saveservice.properties,
+ private static String fileVersion = ""; // computed from saveservice.properties file// $NON-NLS-1$
+ // Must match the sha1 checksum of the file saveservice.properties,
// used to ensure saveservice.properties and SaveService are updated simultaneously
- static final String FILEVERSION = "1709921"; // Expected value $NON-NLS-1$
+ static final String FILEVERSION = "99ce1dfd503fc025603a17c23e25f2d623981cc5"; // Expected value $NON-NLS-1$
private static String fileEncoding = ""; // read from properties file// $NON-NLS-1$
@@ -221,9 +223,34 @@ public class SaveService {
}
return nameMap;
}
+
+ private static String getChecksumForPropertiesFile()
+ throws NoSuchAlgorithmException, IOException {
+ FileInputStream fis = 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);
+ }
+ } finally {
+ JOrphanUtils.closeQuietly(fis);
+ }
+ return JOrphanUtils.baToHexString(md.digest());
+ }
private static void initProps() {
// Load the alias properties
try {
+ fileVersion = getChecksumForPropertiesFile();
+ } catch (IOException | NoSuchAlgorithmException e) {
+ log.fatalError("Can't compute checksum for saveservice properties file", e);
+ throw new JMeterError("JMeter requires the checksum of saveservice properties file to continue", e);
+ }
+ try {
Properties nameMap = loadProperties();
// now create the aliases
for (Map.Entry<Object, Object> me : nameMap.entrySet()) {
@@ -237,8 +264,8 @@ public class SaveService {
propertiesVersion = val;
log.info("Using SaveService properties version " + propertiesVersion);
} else if (key.equalsIgnoreCase("_file_version")) { // $NON-NLS-1$
- fileVersion = extractVersion(val);
- log.info("Using SaveService properties file version " + fileVersion);
+ log.info("SaveService properties file version is now computed by a checksum,"
+ + "the property _file_version is not used anymore and can be removed.");
} else if (key.equalsIgnoreCase("_file_encoding")) { // $NON-NLS-1$
fileEncoding = val;
log.info("Using SaveService properties file encoding " + fileEncoding);
@@ -384,18 +411,6 @@ public class SaveService {
private static boolean versionsOK = true;
- // Extract version digits from String of the form #Revision: n.mm #
- // (where # is actually $ above)
- private static final String REVPFX = "$Revision: ";
- private static final String REVSFX = " $"; // $NON-NLS-1$
-
- private static String extractVersion(String rev) {
- if (rev.length() > REVPFX.length() + REVSFX.length()) {
- return rev.substring(REVPFX.length(), rev.length() - REVSFX.length());
- }
- return rev;
- }
-
// private static void checkVersion(Class clazz, String expected) {
//
// String actual = "*NONE*"; // $NON-NLS-1$
Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1714325&r1=1714324&r2=1714325&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Nov 14 13:48:09 2015
@@ -130,6 +130,7 @@ Summary
<li><bug>57988</bug>Shortcuts (Ctrl+1 .. Ctrl+9) to quick add elements into test plan. Implemented by Andrey Pokhilko (andrey at blazemeter.com) and contributed by BlazeMeter Ltd.</li>
<li><bug>58100</bug>Performance enhancements : Replace Random by ThreadLocalRandom.</li>
<li><bug>58465</bug>JMS Read response field is badly named and documented</li>
+<li><bug>58601</bug>Change check for modification of <code>saveservice.properties</code> from <code>$Revision$</code> to sha1 sum of the file itself.</li>
</ul>
<ch_section>Non-functional changes</ch_section>
<ul>