> From: Christopher Schultz [mailto:ch...@christopherschultz.net] > Subject: Re: svn commit: r1417194 - in > /tomcat/trunk/java/org/apache/tomcat/util/buf: ByteChunk.java CharChunk.java
> On 12/4/12 4:21 PM, ma...@apache.org wrote: > > + private int hashCode=0; > > + // did we compute the hashcode ? > > + private boolean hasHashCode = false; > Should hashCode and hasHashCode be volatile? Yes, to insure program order is followed; otherwise there's no guarantee that hashCode and hasHashCode are written in the required sequence. > In fact, there seems to be much more code in there than necessary. Why not: > > + public int hashCode() { > > + if (hasHashCode) { > > + return hashCode; > > + } > > + hashCode = hash(); > > + hasHashCode = true; > > + return hashCode; Or: public int hashCode() { if (!hasHashCode) { hashCode = hash(); hasHashCode = true; } return hashCode; } - Chuck THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers. --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org