> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: 22 June 2003 04:51
> To: [EMAIL PROTECTED]
> Subject: cvs commit: jakarta-
> cactus/framework/src/java/share/org/apache/cactus
> AbstractWebServerTestCase.java
[snip]
> + private String generateUniqueId() {
> + String id = "testCase:" +this.getClass().getName()+"_";
> + id += "testMethod:" + this.getCurrentTestMethod()+"_";
> + if(wrappingATest()){
> + id += "wrapping:"+wrappedTestName()+"_";
> + }
> + id += "thread:" + Thread.currentThread().toString()+"_";
> + id += "runtime_hash:" +
Runtime.getRuntime().hashCode()+"_";
> + id += "client_ip:" + getIp()+"_";
> + id += "time:" + System.currentTimeMillis()+"_";
> + return id;
> + }
Are we sure we need to add static text to the generated id? (I mean all
the "testCase:", "_", etc?
How confident are we that this leads to a unique id? I'm not sure. What
happens if you're sending several requests on the same machine? The
thread name is often the same. I don't know what the runtime hash is but
I guess it will be same if you're inside the same JVM. The client ip
will be the same. And the currentTimeMillis() will probably be the same
for several requests generated at the same time.
Am I wrong? :-)
Maybe adding a random number would do the trick? Or using an existing
unique id algorithm? There are several that exists on the web. I think
there's even one in the JDK in some RMI-related class (can't remember
right now).
Thanks
-Vincent
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]