[jboss-cvs] JBossAS SVN: r64014 - trunk/ejb3/src/main/org/jboss/ejb3/entity.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 12 16:49:59 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-07-12 16:49:58 -0400 (Thu, 12 Jul 2007)
New Revision: 64014
Modified:
trunk/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java
trunk/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java
trunk/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java
Log:
[EJBTHREE-1010] Don't leak JBC exceptions to clients
Modified: trunk/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java 2007-07-12 20:42:24 UTC (rev 64013)
+++ trunk/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java 2007-07-12 20:49:58 UTC (rev 64014)
@@ -111,7 +111,7 @@
return cache.get( new Fqn( regionFqn, key ), ITEM );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -128,7 +128,7 @@
}
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -151,7 +151,7 @@
log.debug("ignoring write lock acquisition failure");
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
finally {
resume( tx );
@@ -193,7 +193,7 @@
}
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -202,7 +202,7 @@
cache.removeNode( regionFqn );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -227,7 +227,7 @@
}
}
catch( Exception e ) {
- throw new CacheException( e );
+ throw SecondLevelCacheUtil.convertToHibernateException( e );
}
}
@@ -261,7 +261,7 @@
return children == null ? 0 : children.size();
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -286,7 +286,7 @@
return result;
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -297,7 +297,7 @@
return base == null ? null : base.getChildrenNames();
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -322,7 +322,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem activating region " + regionFqn, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
}
@@ -339,7 +339,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem inactivating region " + regionFqn, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
}
Modified: trunk/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java 2007-07-12 20:42:24 UTC (rev 64013)
+++ trunk/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java 2007-07-12 20:49:58 UTC (rev 64014)
@@ -124,7 +124,7 @@
cache.put( new Fqn( regionFqn, key ), ITEM, value );
}
catch ( Exception e ) {
- throw new CacheException( e );
+ throw SecondLevelCacheUtil.convertToHibernateException( e );
}
}
@@ -148,7 +148,7 @@
cache.put( new Fqn( regionFqn, key ), ITEM, value );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -164,7 +164,7 @@
return cache.get( new Fqn( regionFqn, key ), ITEM );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -173,7 +173,7 @@
return cache.get( new Fqn( regionFqn, key ), ITEM );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -186,7 +186,7 @@
cache.put( new Fqn( regionFqn, key ), ITEM, value );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -206,7 +206,7 @@
log.debug("ignoring write lock acquisition failure");
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -226,7 +226,7 @@
}
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -239,7 +239,7 @@
cache.removeNode( regionFqn );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -259,7 +259,7 @@
}
}
catch( Exception e ) {
- throw new CacheException( e );
+ throw SecondLevelCacheUtil.convertToHibernateException( e );
}
}
@@ -293,7 +293,7 @@
return children == null ? 0 : children.size();
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -318,7 +318,7 @@
return result;
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -329,7 +329,7 @@
return base == null ? null : base.getChildrenNames();
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -360,7 +360,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem activating region " + regionFqn, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
}
@@ -377,10 +377,10 @@
}
catch (Exception e)
{
- throw new CacheException("Problem inactivating region " + regionFqn, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
- }
+ }
public static class DataVersionAdapter implements DataVersion
{
Modified: trunk/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java 2007-07-12 20:42:24 UTC (rev 64013)
+++ trunk/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java 2007-07-12 20:49:58 UTC (rev 64014)
@@ -22,9 +22,9 @@
package org.jboss.ejb3.entity;
+import org.hibernate.cache.CacheException;
import org.hibernate.cache.StandardQueryCache;
import org.hibernate.cache.UpdateTimestampsCache;
-import org.jboss.cache.Fqn;
/**
* Utilities related to the Hibernate 2nd Level Cache
@@ -88,6 +88,33 @@
{
return (StandardQueryCache.class.getName().equals(regionName)
|| UpdateTimestampsCache.class.getName().equals(regionName));
+ }
+
+ /**
+ * Creates a CacheException, but doesn't pass JBC CacheException as the cause
+ * as it is a type that likely doesn't exist on a client.
+ * Instead creates a Hibernate CacheException with the original exception's
+ * stack trace.
+ */
+ public static CacheException convertToHibernateException(Exception e)
+ {
+ CacheException he = null;
+
+ if (e instanceof org.jboss.cache.CacheException)
+ {
+ he = new CacheException(e.getClass().getName() + " " + e.getMessage());
+ he.setStackTrace(e.getStackTrace());
+ }
+ else if (e instanceof CacheException)
+ {
+ he = (CacheException) e;
+ }
+ else
+ {
+ he = new CacheException(e);
+ }
+
+ return he;
}
// Prevent instantiation
More information about the jboss-cvs-commits
mailing list