[jbpm-commits] JBoss JBPM SVN: r7058 - in jbpm3/branches/jbpm-3.2-soa/core/src: test/java/org/jbpm/graph/exe and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Feb 21 21:06:33 EST 2012
Author: marco.rietveld
Date: 2012-02-21 21:06:32 -0500 (Tue, 21 Feb 2012)
New Revision: 7058
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/Token.java
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/graph/exe/TokenNameTest.java
Log:
JBPM-3464: NPE when calling Token.hashCode()
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/Token.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/Token.java 2012-02-22 02:04:57 UTC (rev 7057)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/exe/Token.java 2012-02-22 02:06:32 UTC (rev 7058)
@@ -609,8 +609,14 @@
public int hashCode() {
int result = 2080763213 + (name != null ? name.hashCode() : 0);
- result = 1076685199 * result
- + (parent != null ? parent.hashCode() : processInstance.hashCode());
+ result *= 1076685199;
+ // JBPM-3464: processInstance can be null when computing hash code
+ if(parent != null) {
+ result += parent.hashCode();
+ }
+ else if( processInstance != null ) {
+ result += processInstance.hashCode();
+ }
return result;
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/graph/exe/TokenNameTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/graph/exe/TokenNameTest.java 2012-02-22 02:04:57 UTC (rev 7057)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/graph/exe/TokenNameTest.java 2012-02-22 02:06:32 UTC (rev 7058)
@@ -87,4 +87,23 @@
assertNull( pi.findToken( ".." ) );
assertNull( pi.findToken( "/.." ) );
}
+
+ // This test should not throw any NPE's (JBPM-3464)
+ public void testTokenHashCode() throws Exception {
+
+ Token token = new Token();
+ assertTrue( token.hashCode() != 0 );
+
+ token.name = "name";
+ assertTrue( token.hashCode() != 0 );
+
+ Token parent = new Token();
+ parent.name = "parent";
+ token.setParent(parent);
+ assertTrue( token.hashCode() != 0 );
+
+ token.setParent(null);
+ token.setProcessInstance(new ProcessInstance());
+ assertTrue( token.hashCode() != 0 );
+ }
}
More information about the jbpm-commits
mailing list