diff options
author | Burak Emir <emir@epfl.ch> | 2005-12-07 10:41:32 +0000 |
---|---|---|
committer | Burak Emir <emir@epfl.ch> | 2005-12-07 10:41:32 +0000 |
commit | 87052b61f500248b3f7e37da8efa323bedb02189 (patch) | |
tree | 24040ced13f710b14110b1d50c9880cd39ca26cb | |
parent | 5318cffed374df7a8f8042427158fd7fa4834c1f (diff) | |
download | scala-87052b61f500248b3f7e37da8efa323bedb02189.tar.gz scala-87052b61f500248b3f7e37da8efa323bedb02189.tar.bz2 scala-87052b61f500248b3f7e37da8efa323bedb02189.zip |
fixed occasional nullpointer exception due to h...
fixed occasional nullpointer exception due to hashcode computation
-rw-r--r-- | sources/scala/xml/Elem.scala | 3 | ||||
-rw-r--r-- | sources/scala/xml/Node.scala | 2 | ||||
-rw-r--r-- | sources/scala/xml/Utility.scala | 6 |
3 files changed, 9 insertions, 2 deletions
diff --git a/sources/scala/xml/Elem.scala b/sources/scala/xml/Elem.scala index 334344e8f6..6a6d70d1e6 100644 --- a/sources/scala/xml/Elem.scala +++ b/sources/scala/xml/Elem.scala @@ -46,6 +46,9 @@ case class Elem(override val prefix: String, final override def typeTag$: Int = 0; + override def hashCode(): Int = { + Utility.hashCode(prefix, label, attributes.hashCode(), scope.hashCode(), child); + } /** Return a new element with updated attributes * * @param attrs diff --git a/sources/scala/xml/Node.scala b/sources/scala/xml/Node.scala index 9dfd1c3e6c..0bb28e1af1 100644 --- a/sources/scala/xml/Node.scala +++ b/sources/scala/xml/Node.scala @@ -99,7 +99,7 @@ abstract class Node extends NodeSeq { } /** returns a hashcode */ override def hashCode(): Int; - //Utility.hashCode(namespace, label, attributes.hashCode(), child); + //Utility.hashCode(pre, label, attributes.hashCode(), child); /** method for NodeSeq */ diff --git a/sources/scala/xml/Utility.scala b/sources/scala/xml/Utility.scala index ed3ef7a737..2737e75d58 100644 --- a/sources/scala/xml/Utility.scala +++ b/sources/scala/xml/Utility.scala @@ -138,7 +138,11 @@ object Utility extends AnyRef with parsing.TokenTests { * @param children */ def hashCode(pre: String, label: String, attribHashCode: Int, scpeHash: Int, children: Seq[Node]) = { - 41 * pre.hashCode() % 7 + label.hashCode() * 53 + attribHashCode * 7 + scpeHash * 31 + children.hashCode() + ( if(pre!=null) {41 * pre.hashCode() % 7} else {0}) + + label.hashCode() * 53 + + attribHashCode * 7 + + scpeHash * 31 + + children.hashCode() } /** |