You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Brian Lawler <bl...@branuity.com> on 2002/01/05 01:29:01 UTC
UUIdGenerator.java patch...
hello-
We are making extensive use of UUID's in our turbine application here at
branuity, and are using the util.db.UUIdGenerator on advise from John McNally
the w3c generator bases its UUID's off of the localhost IP address. I don't know
if anyone else out there has been using this class, but it seems that there was
a bug in it where the baseId was not being initialized or included in the UUID,
so the resulting id's had the string "null" in them every time.
Attached is the patch that I put in for fixing this, which I coded against the
turbine-2 HEAD.
--
brian lawler
branuity
617 front | v: 415.217.5052
san francisco 94111 | m: 415.307.5277
brian@branuity.com | f: 415.217.5060
Re: UUIdGenerator.java patch...
Posted by Jason van Zyl <jv...@zenplex.com>.
On 1/13/02 1:06 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
> Any comment on this Brian's patch against T2? I didn't noticed this
> class in the decoupled repositories.
>
I don't think I moved this one over to the decoupled tree, but I guess
there's no reason that it can't be moved over.
--
jvz.
Jason van Zyl
http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: UUIdGenerator.java patch...
Posted by Daniel Rall <dl...@finemaltcoding.com>.
Any comment on this Brian's patch against T2? I didn't noticed this
class in the decoupled repositories.
Brian Lawler <bl...@branuity.com> writes:
> We are making extensive use of UUID's in our turbine application
> here at branuity, and are using the util.db.UUIdGenerator on advise
> from John McNally the w3c generator bases its UUID's off of the
> localhost IP address. I don't know if anyone else out there has
> been using this class, but it seems that there was a bug in it where
> the baseId was not being initialized or included in the UUID, so the
> resulting id's had the string "null" in them every time.
>
> Attached is the patch that I put in for fixing this, which I coded against the
> turbine-2 HEAD.
>
> Index: UUIdGenerator.java
> ===================================================================
> RCS file: /home/cvspublic/jakarta-turbine-2/src/java/org/apache/turbine/util/db/UUIdGenerator.java,v
> retrieving revision 1.2
> diff -u -r1.2 UUIdGenerator.java
> --- UUIdGenerator.java 9 Sep 2001 01:31:29 -0000 1.2
> +++ UUIdGenerator.java 5 Jan 2002 00:17:09 -0000
> @@ -177,7 +177,16 @@
> {
> throw new TurbineException( errorString + addr);
> }
> - }
> + }
> + try
> + {
> + generateNewBaseId();
> + }
> + catch (Exception e)
> + {
> + throw new TurbineException( "Failed to generate new base id " +
> + "in constructor", e);
> + }
> }
> /**
> * Generates the new base id
> @@ -186,13 +195,15 @@
> {
> long now = System.currentTimeMillis();
> byte[] nowBytes = org.apache.java.lang.Bytes.toBytes(now);
> + byte[] baseBytes = org.apache.java.lang.Bytes.append(address, nowBytes);
> +
> ByteArrayOutputStream bas = null;
> OutputStream encodedStream = null;
> try
> {
> - bas = new ByteArrayOutputStream(16);
> + bas = new ByteArrayOutputStream(22);
> encodedStream = MimeUtility.encode(bas, "base64");
> - encodedStream.write(nowBytes);
> + encodedStream.write(baseBytes);
> baseId = bas.toString("ISO-8859-1"); // or maybe "US-ASCII"?
> baseId = baseId.replace('/', '_');
> baseId = baseId.replace('*', '-');
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>