Reentrancy problem in generateBranchId()

"Marden P. Marshall" <[email protected]>
Newsgroups gmane.comp.voip.nist-sip
Message-ID <[email protected]>
Under heavy load I have been having problems with 
generateBranchId() throwing the following exception:

java.lang.ArrayIndexOutOfBoundsException
	at java.lang.System.arraycopy(Native Method)
	at 
sun.security.provider.DigestBase.engineUpdate(DigestBase.java:102)
	at sun.security.provider.MD5.implDigest(MD5.java:100)
	at 
sun.security.provider.DigestBase.engineDigest(DigestBase.java:161)
	at 
sun.security.provider.DigestBase.engineDigest(DigestBase.java:140)
	at 
java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:531)
	at 
java.security.MessageDigest.digest(MessageDigest.java:309)
	at 
java.security.MessageDigest.digest(MessageDigest.java:355)
	at 
gov.nist.javax.sip.Utils.generateBranchId(Utils.java:151)
	at 
gov.nist.javax.sip.SipProviderImpl.getNewClientTransaction(SipProviderImpl.java:349)
	at uas.Server.processAck(Server.java:75)
	at uas.Server.processRequest(Server.java:54)
	at 
gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:219)
	at 
gov.nist.javax.sip.SipProviderImpl.handleEvent(SipProviderImpl.java:148)
	at 
gov.nist.javax.sip.DialogFilter.processRequest(DialogFilter.java:902)
	at 
gov.nist.javax.sip.stack.SIPServerTransaction.processRequest(SIPServerTransaction.java:758)
	at 
gov.nist.javax.sip.stack.UDPMessageChannel.run(UDPMessageChannel.java:403)
	at java.lang.Thread.run(Thread.java:613)

By declaring the method to be "synchronized", the problem 
appears to have been resolved.  Here is the diff:

Index: Utils.java
===================================================================
RCS file: 
/cvs/jain-sip/src/gov/nist/javax/sip/Utils.java,v
retrieving revision 1.13
diff -r1.13 Utils.java
146c146
<       public static String generateBranchId() {
---
>       public static synchronized String generateBranchId() {


-Mardy
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.