leif 02/02/06 00:37:47
Modified: src/scratchpad/org/apache/avalon/excalibur/datasource/cluster
DefaultHashedDataSourceCluster.java
Log:
Fix a problem where negative hashCodes were not working correctly
Revision Changes Path
1.2 +5 -2
jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/datasource/cluster/DefaultHashedDataSourceCluster.java
Index: DefaultHashedDataSourceCluster.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/datasource/cluster/DefaultHashedDataSourceCluster.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultHashedDataSourceCluster.java 4 Feb 2002 03:20:54 -0000
1.1
+++ DefaultHashedDataSourceCluster.java 6 Feb 2002 08:37:47 -0000
1.2
@@ -103,7 +103,7 @@
* </pre>
*
* @author <a href="mailto:[EMAIL PROTECTED]">Leif Mortenson</a>
- * @version CVS $Revision: 1.1 $ $Date: 2002/02/04 03:20:54 $
+ * @version CVS $Revision: 1.2 $ $Date: 2002/02/06 08:37:47 $
* @since 4.1
*/
public class DefaultHashedDataSourceCluster
@@ -200,6 +200,9 @@
* DataSources will be provide a Connection.
*/
public int getIndexForHashCode( int hashCode ) {
- return hashCode % getClusterSize();
+ // Hash code may be negative, Make them all positive by using the
unsigned int value.
+ long lHashCode = ((long)hashCode) & 0xffffffffL;
+
+ return (int)(lHashCode % getClusterSize());
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>