JBoss JBPM SVN: r7058 - in jbpm3/branches/jbpm-3.2-soa/core/src: test/java/org/jbpm/graph/exe and 1 other directory.
by do-not-reply@jboss.org
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 );
+ }
}
12 years, 2 months
JBoss JBPM SVN: r7057 - in jbpm3/branches/jbpm-3.2-soa/core/src: test/java/org/jbpm and 1 other directories.
by do-not-reply@jboss.org
Author: marco.rietveld
Date: 2012-02-21 21:04:57 -0500 (Tue, 21 Feb 2012)
New Revision: 7057
Added:
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3423/
jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3423/JBPM3423Test.java
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Node.java
Log:
JBPM-3423 stack overflow/error message when deploying proc defs that contain nodes with same name
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2012-02-22 02:03:22 UTC (rev 7056)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/GraphElement.java 2012-02-22 02:04:57 UTC (rev 7057)
@@ -457,7 +457,18 @@
}
else if (parent instanceof NodeCollection && otherParent instanceof NodeCollection) {
NodeCollection nodeCollection = (NodeCollection) parent;
- int index = nodeCollection.getNodes().indexOf(this);
+
+ // JBPM-3423: equals calls itself recursively via ArrayList.indexOf(this)
+ // hashCode's in Java are not 100% reliable (i.e. NOT always unique)
+ // but reliable enough for this situation
+ Iterator iter = nodeCollection.getNodes().iterator();
+ int index = -1;
+ for( int i = 0; iter.hasNext(); ++i ) {
+ int elemHashCode = System.identityHashCode(iter.next());
+ if( elemHashCode == System.identityHashCode(this) ) {
+ index = i;
+ }
+ }
assert index != -1 : nodeCollection.getNodes();
NodeCollection otherNodeCollection = (NodeCollection) otherParent;
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Node.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Node.java 2012-02-22 02:03:22 UTC (rev 7056)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/graph/def/Node.java 2012-02-22 02:04:57 UTC (rev 7057)
@@ -469,8 +469,7 @@
String oldName = this.name;
if (superState != null) {
if (superState.hasNode(name)) {
- throw new IllegalArgumentException("cannot rename " + this + " because " + superState
- + " already has a node named " + name);
+ throw new IllegalArgumentException("Super state '" + superState + "' already has a node named " + name);
}
Map nodes = superState.getNodesMap();
nodes.remove(oldName);
@@ -478,8 +477,7 @@
}
else if (processDefinition != null) {
if (processDefinition.hasNode(name)) {
- throw new IllegalArgumentException("cannot rename " + this + " because "
- + processDefinition + " already has a node named " + name);
+ throw new IllegalArgumentException("Process definition '" + processDefinition + "' contains two nodes with name " + name);
}
Map nodeMap = processDefinition.getNodesMap();
nodeMap.remove(oldName);
Added: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3423/JBPM3423Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3423/JBPM3423Test.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3423/JBPM3423Test.java 2012-02-22 02:04:57 UTC (rev 7057)
@@ -0,0 +1,82 @@
+package org.jbpm.jbpm3423;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.graph.def.ProcessDefinition;
+
+public class JBPM3423Test extends AbstractDbTestCase {
+
+ private static final String PROCESS_DEFINITION_MULTI_NODE =
+ "<process-definition xmlns='' name='SimpleProcess'>" +
+ " <start-state name='start-state1'>" +
+ " <transition to='SAME'></transition>" +
+ " </start-state>" +
+ " <node name='SAME'>" +
+ " <action class='com.sample.action.MessageActionHandler' name='Node1Action'>" +
+ " <message>NODE-1</message>" +
+ " </action>" +
+ " <transition to='node'></transition>" +
+ " </node>" +
+ " <!-- Because this is ALSO 'SAME', it can cause recursion in the GraphElement.equals(...) method -->" +
+ " <node name='SAME'>" +
+ " <action class='com.sample.action.MessageActionHandler' name='Node2Action'>" +
+ " <message>NODE-2</message>" +
+ " </action>" +
+ " <transition to='end-state1'></transition>" +
+ " </node>" +
+ " <end-state name='end-state1'></end-state>" +
+ "</process-definition>";
+
+
+ private boolean stackOverflow = false;
+ private boolean exceptionWasThrown = false;
+ private boolean threadHadToBeKilled = false;
+
+ public void testNoRecursivenessInParsingNodesWithDuplicateNames() throws Exception {
+ // Thread to deploy process that might stack overflow
+ final Thread deployThread = new Thread() {
+ public void run() {
+ try {
+ ProcessDefinition.parseXmlString(PROCESS_DEFINITION_MULTI_NODE);
+ }
+ catch( Throwable t ) {
+ if( t instanceof StackOverflowError ) {
+ stackOverflow = true;
+ }
+ if( t.getMessage() != null && t.getMessage().contains("contains two nodes") ) {
+ exceptionWasThrown = true;
+ }
+ }
+ }
+ };
+
+ // Timer task to stop above thread if necessary.
+ TimerTask stopThreadTask = new TimerTask() {
+ private Thread threadToStop = deployThread;
+ public void run() {
+ if( threadToStop.isAlive() ) {
+ threadToStop.stop();
+ }
+ }
+ };
+
+ // Setup
+ Timer stopThreadTimer = new Timer();
+ long delay = 2*1000;
+
+ // Start deploy
+ deployThread.start();
+
+ // Kill thread if necessary after delay
+ stopThreadTimer.schedule(stopThreadTask, delay);
+ Thread.sleep(delay + 100);
+
+ assertFalse("Stack overflow occurred!", stackOverflow);
+ assertFalse("Deploy thread had to be killed!", threadHadToBeKilled);
+ assertTrue("No exception was thrown during deployment.", exceptionWasThrown);
+ }
+
+
+}
Property changes on: jbpm3/branches/jbpm-3.2-soa/core/src/test/java/org/jbpm/jbpm3423/JBPM3423Test.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:eol-style
+ native
12 years, 2 months
JBoss JBPM SVN: r7056 - in jbpm3/branches/jbpm-3.2-soa: core/src/main/java/org/jbpm/command and 2 other directories.
by do-not-reply@jboss.org
Author: marco.rietveld
Date: 2012-02-21 21:03:22 -0500 (Tue, 21 Feb 2012)
New Revision: 7056
Modified:
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/ExecuteJobsCommand.java
jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/FieldInfo.java
jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/jpdl.xml
Log:
Random clean up: imports, deleting unused methods, messages, documentation
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2012-02-16 10:29:39 UTC (rev 7055)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/bytes/ByteBlockChopper.java 2012-02-22 02:03:22 UTC (rev 7056)
@@ -23,12 +23,10 @@
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.jbpm.JbpmConfiguration.Configs;
/**
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2012-02-16 10:29:39 UTC (rev 7055)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/CancelProcessInstanceCommand.java 2012-02-22 02:03:22 UTC (rev 7056)
@@ -88,4 +88,6 @@
setProcessInstanceId(processInstanceId);
return this;
}
+
+
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/ExecuteJobsCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/ExecuteJobsCommand.java 2012-02-16 10:29:39 UTC (rev 7055)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/command/ExecuteJobsCommand.java 2012-02-22 02:03:22 UTC (rev 7056)
@@ -1,6 +1,5 @@
package org.jbpm.command;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
@@ -8,7 +7,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
import org.jbpm.JbpmContext;
import org.jbpm.db.JobSession;
import org.jbpm.graph.exe.ProcessInstance;
@@ -111,14 +109,5 @@
if (job.execute(jbpmContext)) jobSession.deleteJob(job);
}
- protected Date getNextDueDate() {
- Date nextDueDate = null;
- JobSession jobSession = jbpmContext.getJobSession();
- Job job = jobSession.getFirstDueJob(getName(), new ArrayList());
- if (job != null) {
- nextDueDate = job.getDueDate();
- }
- return nextDueDate;
- }
}
Modified: jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/FieldInfo.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/FieldInfo.java 2012-02-16 10:29:39 UTC (rev 7055)
+++ jbpm3/branches/jbpm-3.2-soa/core/src/main/java/org/jbpm/configuration/FieldInfo.java 2012-02-22 02:03:22 UTC (rev 7056)
@@ -76,7 +76,7 @@
// keep looking
}
}
- throw new JbpmException("missing field '" + "' in " + type);
+ throw new JbpmException("missing field '" + fieldName + "' in " + type);
}
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/jpdl.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/jpdl.xml 2012-02-16 10:29:39 UTC (rev 7055)
+++ jbpm3/branches/jbpm-3.2-soa/userguide/src/main/docbook/en-US/jpdl.xml 2012-02-22 02:03:22 UTC (rev 7056)
@@ -1056,14 +1056,14 @@
<entry>sub-process</entry>
<entry>element</entry>
<entry>1</entry>
- <entry>This is the sub-process that is associated with this node</entry>
+ <entry>This is the sub-process that is associated with this node.</entry>
</row>
<row>
<entry>variable</entry>
<entry>element</entry>
<entry>[0..*]</entry>
<entry>This specifies how data should be copied from the super-process
- to the sub-process at the commencement, and from the sub-process to the
+ to the sub-process at the commencement, and from the sub-process to the
super-process upon completion, of the sub-process.</entry>
</row>
<row>
12 years, 2 months
JBoss JBPM SVN: r7055 - jbpm3/branches/jbpm-3.2-soa/enterprise-jee5.
by do-not-reply@jboss.org
Author: marco.rietveld
Date: 2012-02-16 05:29:39 -0500 (Thu, 16 Feb 2012)
New Revision: 7055
Removed:
jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.classpath
jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.project
Log:
No editor config in code repo.
Deleted: jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.classpath
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.classpath 2012-02-15 15:57:51 UTC (rev 7054)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.classpath 2012-02-16 10:29:39 UTC (rev 7055)
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" output="target/classes" path="src/main/java"/>
- <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
- <classpathentry kind="output" path="target/classes"/>
-</classpath>
Deleted: jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.project
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.project 2012-02-15 15:57:51 UTC (rev 7054)
+++ jbpm3/branches/jbpm-3.2-soa/enterprise-jee5/.project 2012-02-16 10:29:39 UTC (rev 7055)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>jbpm-ejb3</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.maven.ide.eclipse.maven2Builder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
12 years, 2 months