From dd846638691e3c18cadad095d3ff5bf183d7abba Mon Sep 17 00:00:00 2001 From: Matt Tucker Date: Fri, 25 Apr 2003 20:21:28 +0000 Subject: [PATCH] Lazy load packet id. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1903 b35dd754-fafc-0310-a699-88a17e54d16e --- source/org/jivesoftware/smack/packet/Packet.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/org/jivesoftware/smack/packet/Packet.java b/source/org/jivesoftware/smack/packet/Packet.java index 04e763dc7..0d9d26493 100644 --- a/source/org/jivesoftware/smack/packet/Packet.java +++ b/source/org/jivesoftware/smack/packet/Packet.java @@ -74,7 +74,7 @@ public abstract class Packet { /** * A prefix helps to make sure that ID's are unique across mutliple instances. */ - private static String prefix = StringUtils.randomString(5); + private static String prefix = StringUtils.randomString(5) + "-"; /** * Keeps track of the current increment, which is appended to the prefix to @@ -92,7 +92,7 @@ public abstract class Packet { return prefix + Long.toString(id++); } - private String packetID = nextID(); + private String packetID = null; private String to = null; private String from = null; private Map properties = null; @@ -104,6 +104,9 @@ public abstract class Packet { * @return the packet's unique ID. */ public String getPacketID() { + if (packetID == null) { + packetID = nextID(); + } return packetID; }