View | Details | Raw Unified | Return to bug 58601
Collapse All | Expand All

(-)a/bin/saveservice.properties (-3 / +3 lines)
Lines 34-41 Link Here
34
# Please keep the entries in alphabetical order within the sections
34
# Please keep the entries in alphabetical order within the sections
35
# to reduce the likelihood of duplicates
35
# to reduce the likelihood of duplicates
36
#
36
#
37
# version number of this file (automatically generated by SVN)
37
# version number of this file is now computed by a sha1 sum, so no need for
38
_file_version=$Revision$
38
# an explicit _file_version property anymore
39
#
39
#
40
# Conversion version (for JMX output files)
40
# Conversion version (for JMX output files)
41
# Must be updated if the file has been changed since the previous release
41
# Must be updated if the file has been changed since the previous release
Lines 381-384 _org.apache.jmeter.save.converters.TestResultWrapperConverter=collection Link Here
381
_org.apache.jmeter.save.ScriptWrapperConverter=mapping
381
_org.apache.jmeter.save.ScriptWrapperConverter=mapping
382
#
382
#
383
#	Remember to update the _version entry
383
#	Remember to update the _version entry
384
#
384
#
(-)a/src/core/org/apache/jmeter/save/SaveService.java (-18 / +32 lines)
Lines 29-34 import java.io.OutputStreamWriter; Link Here
29
import java.io.Writer;
29
import java.io.Writer;
30
import java.lang.reflect.InvocationTargetException;
30
import java.lang.reflect.InvocationTargetException;
31
import java.nio.charset.Charset;
31
import java.nio.charset.Charset;
32
import java.security.MessageDigest;
33
import java.security.NoSuchAlgorithmException;
32
import java.util.ArrayList;
34
import java.util.ArrayList;
33
import java.util.List;
35
import java.util.List;
34
import java.util.Map;
36
import java.util.Map;
Lines 180-189 public class SaveService { Link Here
180
    static final String PROPVERSION = "2.9";// Expected version $NON-NLS-1$
182
    static final String PROPVERSION = "2.9";// Expected version $NON-NLS-1$
181
183
182
    // Internal information only
184
    // Internal information only
183
    private static String fileVersion = ""; // read from saveservice.properties file// $NON-NLS-1$
185
    private static String fileVersion = ""; // computed from saveservice.properties file// $NON-NLS-1$
184
    // Must match Revision id value in saveservice.properties, 
186
    // Must match the sha1 checksum of the file saveservice.properties,
185
    // used to ensure saveservice.properties and SaveService are updated simultaneously
187
    // used to ensure saveservice.properties and SaveService are updated simultaneously
186
    static final String FILEVERSION = "1709921"; // Expected value $NON-NLS-1$
188
    static final String FILEVERSION = "99ce1dfd503fc025603a17c23e25f2d623981cc5"; // Expected value $NON-NLS-1$
187
189
188
    private static String fileEncoding = ""; // read from properties file// $NON-NLS-1$
190
    private static String fileEncoding = ""; // read from properties file// $NON-NLS-1$
189
191
Lines 221-229 public class SaveService { Link Here
221
        }
223
        }
222
        return nameMap;
224
        return nameMap;
223
    }
225
    }
226
227
    private static String getChecksumForPropertiesFile()
228
            throws NoSuchAlgorithmException, IOException {
229
        FileInputStream fis = null;
230
        MessageDigest md = MessageDigest.getInstance("SHA1");
231
        try {
232
            fis = new FileInputStream(JMeterUtils.getJMeterHome()
233
                    + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES,
234
                            SAVESERVICE_PROPERTIES_FILE));
235
            byte[] readBuffer = new byte[8192];
236
            int bytesRead;
237
            while ((bytesRead = fis.read(readBuffer)) != -1) {
238
                md.update(readBuffer, 0, bytesRead);
239
            }
240
        } finally {
241
            JOrphanUtils.closeQuietly(fis);
242
        }
243
        return JOrphanUtils.baToHexString(md.digest());
244
    }
224
    private static void initProps() {
245
    private static void initProps() {
225
        // Load the alias properties
246
        // Load the alias properties
226
        try {
247
        try {
248
            fileVersion = getChecksumForPropertiesFile();
249
        } catch (IOException | NoSuchAlgorithmException e) {
250
            log.fatalError("Can't compute checksum for saveservice properties file", e);
251
            throw new JMeterError("JMeter requires the checksum of saveservice properties file to continue", e);
252
        }
253
        try {
227
            Properties nameMap = loadProperties();
254
            Properties nameMap = loadProperties();
228
            // now create the aliases
255
            // now create the aliases
229
            for (Map.Entry<Object, Object> me : nameMap.entrySet()) {
256
            for (Map.Entry<Object, Object> me : nameMap.entrySet()) {
Lines 237-244 public class SaveService { Link Here
237
                        propertiesVersion = val;
264
                        propertiesVersion = val;
238
                        log.info("Using SaveService properties version " + propertiesVersion);
265
                        log.info("Using SaveService properties version " + propertiesVersion);
239
                    } else if (key.equalsIgnoreCase("_file_version")) { // $NON-NLS-1$
266
                    } else if (key.equalsIgnoreCase("_file_version")) { // $NON-NLS-1$
240
                            fileVersion = extractVersion(val);
267
                        log.info("SaveService properties file version is now computed by a checksum,"
241
                            log.info("Using SaveService properties file version " + fileVersion);
268
                                + "the property _file_version is not used anymore and can be removed.");
242
                    } else if (key.equalsIgnoreCase("_file_encoding")) { // $NON-NLS-1$
269
                    } else if (key.equalsIgnoreCase("_file_encoding")) { // $NON-NLS-1$
243
                        fileEncoding = val;
270
                        fileEncoding = val;
244
                        log.info("Using SaveService properties file encoding " + fileEncoding);
271
                        log.info("Using SaveService properties file encoding " + fileEncoding);
Lines 384-401 public class SaveService { Link Here
384
411
385
    private static boolean versionsOK = true;
412
    private static boolean versionsOK = true;
386
413
387
    // Extract version digits from String of the form #Revision: n.mm #
388
    // (where # is actually $ above)
389
    private static final String REVPFX = "$Revision: ";
390
    private static final String REVSFX = " $"; // $NON-NLS-1$
391
392
    private static String extractVersion(String rev) {
393
        if (rev.length() > REVPFX.length() + REVSFX.length()) {
394
            return rev.substring(REVPFX.length(), rev.length() - REVSFX.length());
395
        }
396
        return rev;
397
    }
398
399
//  private static void checkVersion(Class clazz, String expected) {
414
//  private static void checkVersion(Class clazz, String expected) {
400
//
415
//
401
//      String actual = "*NONE*"; // $NON-NLS-1$
416
//      String actual = "*NONE*"; // $NON-NLS-1$
402
- 

Return to bug 58601