1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 20:12:07 +01:00

Lazy load packet id.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1903 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-04-25 20:21:28 +00:00 committed by mtucker
parent 7b02479f66
commit dd84663869

View file

@ -74,7 +74,7 @@ public abstract class Packet {
/** /**
* A prefix helps to make sure that ID's are unique across mutliple instances. * 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 * 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++); return prefix + Long.toString(id++);
} }
private String packetID = nextID(); private String packetID = null;
private String to = null; private String to = null;
private String from = null; private String from = null;
private Map properties = null; private Map properties = null;
@ -104,6 +104,9 @@ public abstract class Packet {
* @return the packet's unique ID. * @return the packet's unique ID.
*/ */
public String getPacketID() { public String getPacketID() {
if (packetID == null) {
packetID = nextID();
}
return packetID; return packetID;
} }