[jbpm-commits] JBoss JBPM SVN: r5486 - in jbpm3/branches/jbpm-3.2-soa/modules: core/src/main/java/org/jbpm/db and 11 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Aug 18 05:54:02 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-08-18 05:54:01 -0400 (Tue, 18 Aug 2009)
New Revision: 5486
Added:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java
Removed:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml
Modified:
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java
jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java
jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
Log:
[JBPM-2488] jBPM exception logging can block execution of all processes
cap length of stack traces
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/AbstractJbpmTestCase.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -21,12 +21,13 @@
*/
package org.jbpm;
-import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jbpm.util.ClassUtil;
+
public abstract class AbstractJbpmTestCase extends TestCase {
private static Log log = LogFactory.getLog(AbstractJbpmTestCase.class);
@@ -44,21 +45,10 @@
}
protected String getShortName() {
- String shortName = getClass().getName();
- return shortName.substring(shortName.lastIndexOf('.') + 1) + "." + getName();
+ return ClassUtil.getSimpleName(getClass()) + '.' + getName();
}
protected String getLongName() {
- return getClass().getName() + "." + getName();
+ return getClass().getName() + '.' + getName();
}
-
- protected void runTest() throws Throwable {
- try {
- super.runTest();
- }
- catch (AssertionFailedError e) {
- log.error("ASSERTION FAILURE: " + e.getMessage());
- throw e;
- }
- }
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/AbstractDbTestCase.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -64,6 +64,17 @@
beginSessionTransaction();
}
+ protected void runTest() throws Throwable {
+ try {
+ super.runTest();
+ }
+ catch (Exception e) {
+ // prevent unsafe use of the session after an exception occurs
+ jbpmContext.setRollbackOnly();
+ throw e;
+ }
+ }
+
protected void tearDown() throws Exception {
commitAndCloseSession();
ensureCleanDatabase();
@@ -84,14 +95,8 @@
Long count = (Long) entry.getValue();
if (count.intValue() != 0) {
hasLeftOvers = true;
- System.err.println("FIXME: " +
- getClass().getName() +
- "." +
- getName() +
- " left " +
- count +
- " records in " +
- entry.getKey());
+ System.err.println("FIXME: " + getClass().getName() + "." + getName() + " left "
+ + count + " records in " + entry.getKey());
}
}
@@ -201,7 +206,8 @@
}
if (currentCount < previousCount) {
- waitPeriod = currentCount * (currentTime - previousTime) / (previousCount - currentCount);
+ waitPeriod = currentCount * (currentTime - previousTime)
+ / (previousCount - currentCount);
if (waitPeriod < 500) waitPeriod = 500;
}
else {
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/HibernateHelper.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -23,7 +23,9 @@
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
+import java.sql.PreparedStatement;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -42,8 +44,10 @@
// prevent instantiation
}
- /** maps SessionFactory's to Configurations.
- * by default, configuration lookup will be enabled */
+ /**
+ * maps SessionFactory's to Configurations.<br>
+ * by default, configuration lookup will be enabled
+ */
static Map configurations = new HashMap();
public static void clearConfigurationsCache() {
@@ -58,7 +62,8 @@
return createSessionFactory(cfgXmlResource, null, true);
}
- public static SessionFactory createSessionFactory(String cfgXmlResource, String propertiesResource) {
+ public static SessionFactory createSessionFactory(String cfgXmlResource,
+ String propertiesResource) {
return createSessionFactory(cfgXmlResource, propertiesResource, true);
}
@@ -77,23 +82,24 @@
return sessionFactory;
}
- public static Configuration createConfiguration(String cfgXmlResource, String propertiesResource) {
+ public static Configuration createConfiguration(String cfgXmlResource,
+ String propertiesResource) {
Configuration configuration = new Configuration();
// if a special hibernate configuration xml file is specified,
if (cfgXmlResource != null) {
// use the configured file name
- URL cfgURL = Thread.currentThread().getContextClassLoader().getResource(cfgXmlResource);
- log.debug("creating hibernate configuration resource '" + cfgURL + "'");
+ log.debug("using hibernate configuration resource: " + cfgXmlResource);
configuration.configure(cfgXmlResource);
- } else {
- log.debug("using default hibernate configuration resource (hibernate.cfg.xml)");
+ }
+ else {
+ log.debug("using default hibernate configuration resource: hibernate.cfg.xml");
configuration.configure();
}
// if the properties are specified in a separate file
if (propertiesResource != null) {
- log.debug("using hibernate properties from resource '" + propertiesResource + "'");
+ log.debug("using hibernate properties resource: " + propertiesResource);
// load the properties
Properties properties = loadPropertiesFromResource(propertiesResource);
if (!properties.isEmpty()) {
@@ -114,27 +120,21 @@
}
public static boolean createSchemaExportScript(SessionFactory sessionFactory) {
- boolean script = false;
String showSql = getConfiguration(sessionFactory).getProperty("hibernate.show_sql");
- if ("true".equalsIgnoreCase(showSql)) {
- script = true;
- }
- return script;
+ return "true".equalsIgnoreCase(showSql);
}
public static void clearHibernateCache(SessionFactory sessionFactory) {
sessionFactory.evictQueries();
Map classMetadata = sessionFactory.getAllClassMetadata();
- Iterator iter = classMetadata.keySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = classMetadata.keySet().iterator(); iter.hasNext();) {
String entityName = (String) iter.next();
sessionFactory.evictEntity(entityName);
}
Map collectionMetadata = sessionFactory.getAllCollectionMetadata();
- iter = collectionMetadata.keySet().iterator();
- while (iter.hasNext()) {
+ for (Iterator iter = collectionMetadata.keySet().iterator(); iter.hasNext();) {
String collectionName = (String) iter.next();
sessionFactory.evictCollection(collectionName);
}
@@ -146,12 +146,14 @@
if (inputStream != null) {
try {
properties.load(inputStream);
- } catch (IOException e) {
- log.warn("couldn't load hibernate properties from resource '" + resource + "'", e);
}
- } else {
- log.warn("hibernate properties resource '" + resource + "' not found");
+ catch (IOException e) {
+ log.warn("could not load hibernate properties from resource: " + resource, e);
+ }
}
+ else {
+ log.warn("hibernate properties resource not found: " + resource);
+ }
return properties;
}
Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedStringType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -0,0 +1,55 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db.hibernate;
+
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.type.StringType;
+import org.hibernate.usertype.ParameterizedType;
+
+/**
+ * Mapping between SQL {@link Types#VARCHAR varchar} and Java {@link String} that truncates
+ * parameter values to column size.
+ *
+ * @author Alejandro Guizar
+ */
+public class LimitedStringType extends StringType implements ParameterizedType {
+
+ private int limit;
+
+ private static final long serialVersionUID = 1L;
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ String text = (String) value;
+ if (text.length() > limit) text = text.substring(0, limit);
+
+ st.setString(index, text);
+ }
+
+ public void setParameterValues(Properties parameters) {
+ limit = Integer.parseInt(parameters.getProperty("limit"));
+ }
+
+}
Added: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/LimitedTextType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db.hibernate;
+
+import java.io.StringReader;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.Properties;
+
+import org.hibernate.type.TextType;
+import org.hibernate.usertype.ParameterizedType;
+
+/**
+ * Mapping between SQL {@link Types#CLOB clob} and Java {@link String} that truncates parameter
+ * values to column size.
+ *
+ * @author Alejandro Guizar
+ */
+public class LimitedTextType extends TextType implements ParameterizedType {
+
+ private int limit;
+
+ private static final long serialVersionUID = 1L;
+
+ public void set(PreparedStatement st, Object value, int index) throws SQLException {
+ String text = (String) value;
+ if (text.length() > limit) text = text.substring(0, limit);
+
+ st.setCharacterStream(index, new StringReader(text), text.length());
+ }
+
+ public void setParameterValues(Properties parameters) {
+ limit = Integer.parseInt(parameters.getProperty("limit"));
+ }
+
+}
Copied: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java (from rev 5163, jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java)
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java (rev 0)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/SybaseTextType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -0,0 +1,245 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.db.hibernate;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Serializable;
+import java.io.StringReader;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.type.Type;
+import org.hibernate.usertype.EnhancedUserType;
+import org.hibernate.util.EqualsHelper;
+import org.hibernate.util.StringHelper;
+
+/**
+ * Replacement for {@link org.hibernate.type.TextType} made to work around a <em>feature</em> in the
+ * jConnect driver when setting a text parameter to <code>null</code>. Specifically, the call:
+ *
+ * <pre>
+ * PreparedStatement st;
+ * st.setNull(index, Types.CLOB);
+ * </pre>
+ *
+ * throws an SQLException with SQL state "JZ0SL" and reason "Unsupported SQL type".
+ *
+ * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1818">JBPM-1818</a>
+ * @author Alejandro Guizar
+ */
+public class SybaseTextType implements EnhancedUserType, Serializable {
+
+ private transient Log log;
+ private static final boolean IS_VALUE_TRACING_ENABLED =
+ LogFactory.getLog(StringHelper.qualifier(Type.class.getName())).isTraceEnabled();
+
+ private static final long serialVersionUID = 1L;
+
+ private Log log() {
+ if (log == null) {
+ log = LogFactory.getLog(getClass());
+ }
+ return log;
+ }
+
+ public Object assemble(Serializable cached, Object owner) throws HibernateException {
+ return cached != null ? deepCopy(cached) : null;
+ }
+
+ public Object deepCopy(Object value) throws HibernateException {
+ return value;
+ }
+
+ public Serializable disassemble(Object value) throws HibernateException {
+ return value != null ? (Serializable) deepCopy(value) : null;
+ }
+
+ public boolean equals(Object x, Object y) throws HibernateException {
+ return EqualsHelper.equals(x, y);
+ }
+
+ public int hashCode(Object x) throws HibernateException {
+ return x.hashCode();
+ }
+
+ public boolean isMutable() {
+ return false;
+ }
+
+ public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException,
+ SQLException {
+ return nullSafeGet(rs, names[0]);
+ }
+
+ public Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException {
+ try {
+ Object value = get(rs, name);
+ if (value == null) {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("returning null as column: " + name);
+ }
+ return null;
+ }
+ else {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("returning '" + toString(value) + "' as column: " + name);
+ }
+ return value;
+ }
+ }
+ catch (RuntimeException re) {
+ log().info("could not read column value from result set: " + name + "; " + re.getMessage());
+ throw re;
+ }
+ catch (SQLException se) {
+ log().info("could not read column value from result set: " + name + "; " + se.getMessage());
+ throw se;
+ }
+ }
+
+ public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
+ // retrieve the value of the designated column in the current row of the
+ // result set as a character reader
+ Reader charReader = rs.getCharacterStream(name);
+
+ // if the corresponding SQL value is NULL, the reader we got is NULL as well
+ if (charReader == null || rs.wasNull()) return null;
+
+ // Fetch Reader content up to the end - and put characters in a StringBuffer
+ StringBuffer sbuf = new StringBuffer();
+ try {
+ char[] cbuf = new char[1024];
+ for (int amountRead; (amountRead = charReader.read(cbuf)) != -1;) {
+ sbuf.append(cbuf, 0, amountRead);
+ }
+ }
+ catch (IOException ioe) {
+ throw new HibernateException("IOException occurred reading text", ioe);
+ }
+ finally {
+ try {
+ charReader.close();
+ }
+ catch (IOException e) {
+ throw new HibernateException("IOException occurred closing stream", e);
+ }
+ }
+
+ // Return StringBuffer content as a large String
+ return sbuf.toString();
+ }
+
+ public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException,
+ SQLException {
+ try {
+ if (value == null) {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("binding null to parameter: " + index);
+ }
+
+ setNull(st, index);
+ }
+ else {
+ if (IS_VALUE_TRACING_ENABLED) {
+ log().trace("binding '" + toString(value) + "' to parameter: " + index);
+ }
+
+ set(st, value, index);
+ }
+ }
+ catch (RuntimeException re) {
+ log().info("could not bind value '" +
+ nullSafeToString(value) +
+ "' to parameter: " +
+ index +
+ "; " +
+ re.getMessage());
+ throw re;
+ }
+ catch (SQLException se) {
+ log().info("could not bind value '" +
+ nullSafeToString(value) +
+ "' to parameter: " +
+ index +
+ "; " +
+ se.getMessage());
+ throw se;
+ }
+ }
+
+ public void set(PreparedStatement st, Object value, int index) throws HibernateException,
+ SQLException {
+ String str = (String) value;
+ st.setCharacterStream(index, new StringReader(str), str.length());
+ }
+
+ public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException {
+ // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with jConnect
+ st.setCharacterStream(index, null, 0);
+ }
+
+ public Object replace(Object original, Object target, Object owner) throws HibernateException {
+ return original;
+ }
+
+ public Class returnedClass() {
+ return String.class;
+ }
+
+ public int[] sqlTypes() {
+ return new int[] { sqlType() };
+ }
+
+ public int sqlType() {
+ return Types.CLOB;
+ }
+
+ public String objectToSQLString(Object value) {
+ return '\'' + (String) value + '\'';
+ }
+
+ public Object fromXMLString(String xml) {
+ return xml != null && xml.length() > 0 ? fromStringValue(xml) : null;
+ }
+
+ public String toXMLString(Object value) {
+ return toString(value);
+ }
+
+ public String nullSafeToString(Object value) throws HibernateException {
+ return value != null ? toString(value) : null;
+ }
+
+ public String toString(Object value) {
+ return (String) value;
+ }
+
+ public Object fromStringValue(String xml) {
+ return xml;
+ }
+}
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/db/hibernate/TextType.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -1,245 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jbpm.db.hibernate;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Serializable;
-import java.io.StringReader;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.hibernate.HibernateException;
-import org.hibernate.type.Type;
-import org.hibernate.usertype.EnhancedUserType;
-import org.hibernate.util.EqualsHelper;
-import org.hibernate.util.StringHelper;
-
-/**
- * Replacement for {@link org.hibernate.type.TextType} made to work around a <em>feature</em> in the
- * jConnect driver when setting a text parameter to <code>null</code>. Specifically, the call:
- *
- * <pre>
- * PreparedStatement st;
- * st.setNull(index, Types.CLOB);
- * </pre>
- *
- * throws an SQLException with SQL state "JZ0SL" and reason "Unsupported SQL type".
- *
- * @see <a href="https://jira.jboss.org/jira/browse/JBPM-1818">JBPM-1818</a>
- * @author Alejandro Guizar
- */
-public class TextType implements EnhancedUserType, Serializable {
-
- private transient Log log;
- private static final boolean IS_VALUE_TRACING_ENABLED =
- LogFactory.getLog(StringHelper.qualifier(Type.class.getName())).isTraceEnabled();
-
- private static final long serialVersionUID = 1L;
-
- private Log log() {
- if (log == null) {
- log = LogFactory.getLog(getClass());
- }
- return log;
- }
-
- public Object assemble(Serializable cached, Object owner) throws HibernateException {
- return cached != null ? deepCopy(cached) : null;
- }
-
- public Object deepCopy(Object value) throws HibernateException {
- return value;
- }
-
- public Serializable disassemble(Object value) throws HibernateException {
- return value != null ? (Serializable) deepCopy(value) : null;
- }
-
- public boolean equals(Object x, Object y) throws HibernateException {
- return EqualsHelper.equals(x, y);
- }
-
- public int hashCode(Object x) throws HibernateException {
- return x.hashCode();
- }
-
- public boolean isMutable() {
- return false;
- }
-
- public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException,
- SQLException {
- return nullSafeGet(rs, names[0]);
- }
-
- public Object nullSafeGet(ResultSet rs, String name) throws HibernateException, SQLException {
- try {
- Object value = get(rs, name);
- if (value == null) {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("returning null as column: " + name);
- }
- return null;
- }
- else {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("returning '" + toString(value) + "' as column: " + name);
- }
- return value;
- }
- }
- catch (RuntimeException re) {
- log().info("could not read column value from result set: " + name + "; " + re.getMessage());
- throw re;
- }
- catch (SQLException se) {
- log().info("could not read column value from result set: " + name + "; " + se.getMessage());
- throw se;
- }
- }
-
- public Object get(ResultSet rs, String name) throws HibernateException, SQLException {
- // retrieve the value of the designated column in the current row of the
- // result set as a character reader
- Reader charReader = rs.getCharacterStream(name);
-
- // if the corresponding SQL value is NULL, the reader we got is NULL as well
- if (charReader == null || rs.wasNull()) return null;
-
- // Fetch Reader content up to the end - and put characters in a StringBuffer
- StringBuffer sbuf = new StringBuffer();
- try {
- char[] cbuf = new char[1024];
- for (int amountRead; (amountRead = charReader.read(cbuf)) != -1;) {
- sbuf.append(cbuf, 0, amountRead);
- }
- }
- catch (IOException ioe) {
- throw new HibernateException("IOException occurred reading text", ioe);
- }
- finally {
- try {
- charReader.close();
- }
- catch (IOException e) {
- throw new HibernateException("IOException occurred closing stream", e);
- }
- }
-
- // Return StringBuffer content as a large String
- return sbuf.toString();
- }
-
- public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException,
- SQLException {
- try {
- if (value == null) {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("binding null to parameter: " + index);
- }
-
- setNull(st, index);
- }
- else {
- if (IS_VALUE_TRACING_ENABLED) {
- log().trace("binding '" + toString(value) + "' to parameter: " + index);
- }
-
- set(st, value, index);
- }
- }
- catch (RuntimeException re) {
- log().info("could not bind value '" +
- nullSafeToString(value) +
- "' to parameter: " +
- index +
- "; " +
- re.getMessage());
- throw re;
- }
- catch (SQLException se) {
- log().info("could not bind value '" +
- nullSafeToString(value) +
- "' to parameter: " +
- index +
- "; " +
- se.getMessage());
- throw se;
- }
- }
-
- public void set(PreparedStatement st, Object value, int index) throws HibernateException,
- SQLException {
- String str = (String) value;
- st.setCharacterStream(index, new StringReader(str), str.length());
- }
-
- public void setNull(PreparedStatement st, int index) throws HibernateException, SQLException {
- // JBPM-1818: workaround for SQL state JZ0SL: "Unsupported SQL type" with jConnect
- st.setCharacterStream(index, null, 0);
- }
-
- public Object replace(Object original, Object target, Object owner) throws HibernateException {
- return original;
- }
-
- public Class returnedClass() {
- return String.class;
- }
-
- public int[] sqlTypes() {
- return new int[] { sqlType() };
- }
-
- public int sqlType() {
- return Types.CLOB;
- }
-
- public String objectToSQLString(Object value) {
- return '\'' + (String) value + '\'';
- }
-
- public Object fromXMLString(String xml) {
- return xml != null && xml.length() > 0 ? fromStringValue(xml) : null;
- }
-
- public String toXMLString(Object value) {
- return toString(value);
- }
-
- public String nullSafeToString(Object value) throws HibernateException {
- return value != null ? toString(value) : null;
- }
-
- public String toString(Object value) {
- return (String) value;
- }
-
- public Object fromStringValue(String xml) {
- return xml;
- }
-}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/instantiation/Delegation.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -60,12 +60,12 @@
return instantiators;
}
- long id = 0;
- protected String className = null;
- protected String configuration = null;
- protected String configType = null;
- protected ProcessDefinition processDefinition = null;
- transient Object instance = null;
+ long id;
+ protected String className;
+ protected String configuration;
+ protected String configType;
+ protected ProcessDefinition processDefinition;
+ transient Object instance;
public Delegation() {
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/java/org/jbpm/job/executor/JobExecutorThread.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -43,8 +43,8 @@
* @deprecated use {@link #JobExecutorThread(String, JobExecutor)} instead
*/
public JobExecutorThread(String name, JobExecutor jobExecutor,
- JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval, long maxLockTime,
- int maxHistory) {
+ JbpmConfiguration jbpmConfiguration, int idleInterval, int maxIdleInterval,
+ long maxLockTime, int maxHistory) {
super(name);
this.jobExecutor = jobExecutor;
this.jbpmConfiguration = jbpmConfiguration;
@@ -82,18 +82,18 @@
}
}
catch (InterruptedException ie) {
- log.debug("delay after exception got interrupted", ie);
+ log.debug(getName() + " got interrupted: " + e.getMessage());
}
- // after an exception, the current idle interval is doubled to prevent
- // continuous exception generation when e.g. the db is unreachable
- currentIdleInterval <<= 1;
+ // after an exception, double the current idle interval to prevent
+ // continuous exception throwing while an anomalous condition prevails
+ currentIdleInterval *= 2;
if (currentIdleInterval > maxIdleInterval || currentIdleInterval < 0) {
currentIdleInterval = maxIdleInterval;
}
}
}
catch (InterruptedException e) {
- log.info(getName() + " got interrupted");
+ log.debug(getName() + " got interrupted: " + e.getMessage());
}
}
log.info(getName() + " leaves cyberspace");
@@ -182,7 +182,7 @@
job.setRetries(job.getRetries() - 1);
}
else {
- // allowing a transaction to proceed after a persistence exception is unsafe
+ // prevent unsafe use of the session after an exception occurs
jbpmContext.setRollbackOnly();
}
}
@@ -204,8 +204,8 @@
catch (RuntimeException e) {
if (!DbPersistenceService.isLockingException(e)) throw e;
// if this is a locking exception, keep it quiet
- StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("failed to complete job " +
- job);
+ StaleObjectLogConfigurer.getStaleObjectExceptionsLog().error("failed to complete job "
+ + job);
}
}
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/hibernate.mapping.sybase.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -97,7 +97,7 @@
<mapping resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
<!-- job mapping files -->
- <mapping resource="org/jbpm/job/Job.sybase.hbm.xml"/>
+ <mapping resource="org/jbpm/job/Job.hbm.xml"/>
<mapping resource="org/jbpm/job/Timer.hbm.xml"/>
<mapping resource="org/jbpm/job/ExecuteNodeJob.hbm.xml"/>
<mapping resource="org/jbpm/job/ExecuteActionJob.hbm.xml"/>
@@ -113,7 +113,7 @@
<mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
<mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
<mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
- <mapping resource="org/jbpm/graph/log/ActionLog.sybase.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
<mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
<mapping resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
<mapping resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.db2.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -4,5 +4,8 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
- <typedef name="longstring" class="org.hibernate.type.TextType" />
+ <typedef name="longstring" class="org.hibernate.type.TextType"/>
+ <typedef name="ltdstring" class="org.jbpm.db.hibernate.LimitedTextType">
+ <param name="limit">4000</param>
+ </typedef>
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -4,5 +4,8 @@
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
- <typedef name="longstring" class="org.hibernate.type.StringType" />
+ <typedef name="longstring" class="org.hibernate.type.StringType"/>
+ <typedef name="ltdstring" class="org.jbpm.db.hibernate.LimitedStringType">
+ <param name="limit">4000</param>
+ </typedef>
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/db/hibernate.types.sybase.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -5,5 +5,5 @@
<hibernate-mapping>
<typedef name="longstring" class="org.hibernate.type.StringType" />
- <typedef name="text" class="org.jbpm.db.hibernate.TextType" />
+ <typedef name="ltdstring" class="org.jbpm.db.hibernate.SybaseTextType" />
</hibernate-mapping>
\ No newline at end of file
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/default.jbpm.cfg.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -63,7 +63,6 @@
<field name="nbrOfThreads"><int value="1" /></field>
<field name="idleInterval"><int value="5000" /></field>
<field name="maxIdleInterval"><int value="3600000" /></field> <!-- 1 hour -->
- <field name="historyMaxSize"><int value="20" /></field>
<field name="maxLockTime"><int value="600000" /></field> <!-- 10 minutes -->
<field name="lockMonitorInterval"><int value="60000" /></field> <!-- 1 minute -->
<field name="lockBufferTime"><int value="5000" /></field> <!-- 5 seconds -->
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -10,7 +10,7 @@
extends="org.jbpm.logging.log.CompositeLog"
discriminator-value="A">
- <property name="exception" column="EXCEPTION_" type="longstring" length="4000"/>
+ <property name="exception" column="EXCEPTION_" type="ltdstring" length="4000"/>
<many-to-one name="action"
column="ACTION_"
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/graph/log/ActionLog.sybase.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -1,21 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping auto-import="false" default-access="field">
-
- <subclass name="org.jbpm.graph.log.ActionLog"
- extends="org.jbpm.logging.log.CompositeLog"
- discriminator-value="A">
-
- <property name="exception" column="EXCEPTION_" type="text" length="4000"/>
-
- <many-to-one name="action"
- column="ACTION_"
- foreign-key="FK_LOG_ACTION"
- index="IDX_LOG_ACTION" />
- </subclass>
-
-</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -35,7 +35,7 @@
<property name="isExclusive" column="ISEXCLUSIVE_" />
<property name="lockOwner" column="LOCKOWNER_" />
<property name="lockTime" column="LOCKTIME_" />
- <property name="exception" column="EXCEPTION_" type="longstring" length="4000" />
+ <property name="exception" column="EXCEPTION_" type="ltdstring" length="4000" />
<property name="retries" column="RETRIES_" />
</class>
Deleted: jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/main/resources/org/jbpm/job/Job.sybase.hbm.xml 2009-08-18 09:54:01 UTC (rev 5486)
@@ -1,43 +0,0 @@
-<?xml version="1.0"?>
-
-<!DOCTYPE hibernate-mapping PUBLIC
- "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
- "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping auto-import="false" default-access="field">
-
- <class name="org.jbpm.job.Job" table="JBPM_JOB" discriminator-value="J">
- <id name="id" column="ID_">
- <generator class="native" />
- </id>
- <discriminator type="char" column="CLASS_" />
- <version name="version" column="VERSION_" />
-
- <property name="dueDate" column="DUEDATE_" type="timestamp" />
-
- <many-to-one name="processInstance"
- column="PROCESSINSTANCE_"
- cascade="lock"
- foreign-key="FK_JOB_PRINST"
- index="IDX_JOB_PRINST" />
- <many-to-one name="token"
- column="TOKEN_"
- cascade="lock"
- foreign-key="FK_JOB_TOKEN"
- index="IDX_JOB_TOKEN" />
- <many-to-one name="taskInstance"
- column="TASKINSTANCE_"
- cascade="lock"
- foreign-key="FK_JOB_TSKINST"
- index="IDX_JOB_TSKINST" />
-
- <property name="isSuspended" column="ISSUSPENDED_" />
- <property name="isExclusive" column="ISEXCLUSIVE_" />
- <property name="lockOwner" column="LOCKOWNER_" />
- <property name="lockTime" column="LOCKTIME_" />
- <property name="exception" column="EXCEPTION_" type="text" length="4000" />
- <property name="retries" column="RETRIES_" />
-
- </class>
-
-</hibernate-mapping>
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/graph/log/ActionLogDbTest.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -24,49 +24,60 @@
import java.io.PrintWriter;
import java.io.StringWriter;
+import org.hibernate.type.Type;
+
import org.jbpm.db.AbstractDbTestCase;
+import org.jbpm.db.hibernate.LimitedStringType;
+import org.jbpm.db.hibernate.LimitedTextType;
import org.jbpm.graph.def.Action;
-public class ActionLogDbTest extends AbstractDbTestCase
-{
- public void testActionLog()
- {
+public class ActionLogDbTest extends AbstractDbTestCase {
+
+ public void testActionLog() {
Action action = new Action();
session.save(action);
-
+
ActionLog actionLog = new ActionLog(action);
- actionLog = (ActionLog)saveAndReload(actionLog);
+ actionLog = (ActionLog) saveAndReload(actionLog);
assertNotNull(actionLog.getAction());
-
+
session.delete(actionLog);
session.delete(action);
}
- public void testActionExceptionLog()
- {
- RuntimeException rte = getRuntimeException();
- StringWriter stwr = new StringWriter();
- PrintWriter prwr = new PrintWriter(stwr);
- rte.printStackTrace(prwr);
-
+ public void testActionExceptionLog() {
+ RuntimeException exception = createExceptionChain(null, 0);
+
ActionLog actionLog = new ActionLog();
- actionLog.setException(rte);
- actionLog = (ActionLog)saveAndReload(actionLog);
-
- String rteStr = actionLog.getException();
- assertNotNull("Exception not null", rteStr);
- assertEquals("Exception string", stwr.toString().length(), rteStr.length());
-
+ actionLog.setException(exception);
+ actionLog = (ActionLog) saveAndReload(actionLog);
+
+ String exceptionString = actionLog.getException();
+ assertNotNull("log exception is null", exceptionString);
+
+ int expectedLength = 4000;
+ if (!isLimitEnforced()) {
+ StringWriter exceptionWriter = new StringWriter();
+ exception.printStackTrace(new PrintWriter(exceptionWriter));
+ expectedLength = exceptionWriter.getBuffer().length();
+ assert expectedLength > 4000 : expectedLength;
+ }
+
+ int actualLength = exceptionString.length();
+ assert actualLength == expectedLength : actualLength;
+
session.delete(actionLog);
}
- private RuntimeException getRuntimeException()
- {
- RuntimeException rte = new RuntimeException("level 0");
- for (int level = 0; level < 10; level++)
- {
- rte = new RuntimeException("level " + level, rte);
- }
- return rte;
+ private boolean isLimitEnforced() {
+ Type propertyType = session.getSessionFactory()
+ .getClassMetadata(ActionLog.class)
+ .getPropertyType("exception");
+ return propertyType instanceof LimitedStringType || propertyType instanceof LimitedTextType;
}
+
+ private RuntimeException createExceptionChain(RuntimeException cause, int level) {
+ return level == 100 ? cause : createExceptionChain(level % 10 == 0 ? new RuntimeException(
+ "level " + level, cause) : cause, level + 1);
+ }
}
Modified: jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/core/src/test/java/org/jbpm/jbpm2375/JBPM2375Test.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -28,7 +28,7 @@
" <transition to='state1' name='to_state1'/>" +
" </start-state>" +
" <state name='state1'>" +
- " <timer name='moveToDefaultEndAfter1second' duedate='1 second' transition='to_state2'/>" +
+ " <timer name='moveToNextStateAfter1second' duedate='1 second' transition='to_state2'/>" +
" <transition to='state2' name='to_state2'/>" +
" </state>" +
" <state name='state2'>" +
@@ -46,7 +46,7 @@
protected void setUp() throws Exception {
super.setUp();
- jbpmConfiguration.getJobExecutor().setLockMonitorInterval(TEST_TIMEOUT / 2);
+ jbpmConfiguration.getJobExecutor().setLockMonitorInterval(TEST_TIMEOUT / 6);
processDefinition = ProcessDefinition.parseXmlString(PROCESS_DEFINITION);
jbpmContext.deployProcessDefinition(processDefinition);
Modified: jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java
===================================================================
--- jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-08-18 08:17:27 UTC (rev 5485)
+++ jbpm3/branches/jbpm-3.2-soa/modules/enterprise/src/main/java/org/jbpm/ejb/impl/ExecuteJobCommand.java 2009-08-18 09:54:01 UTC (rev 5486)
@@ -87,7 +87,7 @@
job.setException(memoryWriter.toString());
}
else {
- // allowing a transaction to proceed after a persistence exception is unsafe
+ // prevent unsafe use of the session after an exception occurs
throw e instanceof RuntimeException ? (RuntimeException) e :
new JbpmException("failed to execute " + job, e);
}
More information about the jbpm-commits
mailing list