Greetings, hackers,
Hongbing discovered the following code in the JUnit sensor today, which can
result in unit test timestamps being up to an hour off when sent to the
server. Does anyone remember writing this code, and remember the
circumstances under which it was needed? We'd like to make the timestamps
a little closer to reality if possible.
Thanks!
Philip
260 /**
261 * Computes a long value from the passed String. Equal strings will
always
262 * compute the same long value and unequal strings will (usually)
compute a different
263 * long value. This value is added on to the startTime associated
with that TestClass (which
264 * is itself determined by the file's last mod date.
265 * The value computed generally varies between 70,000 and 250,000
(i.e. 70 and 250 seconds). This
266 * hash is used to solve the problem of multiple files with the same
last mod time being sent
267 * by different sensor shell instances (which results in clobbering of
the data on the server
268 * side.)
269 *
270 * @param testClassName The name of the test class whose hash is to be
computed.
271 * @return A hash value (generally between about 70,000 and 250,000).
272 */
273 private long computeFileHash(String testClassName) {
274 long hash = 0;
275 for (int i = 0; i < testClassName.length(); i++) {
276 hash += (testClassName.charAt(i) * i);
277 }
278 return hash;
279 }