[jboss-cvs] JBossAS SVN: r64018 - branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jul 12 17:50:41 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-07-12 17:50:40 -0400 (Thu, 12 Jul 2007)
New Revision: 64018
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java
Log:
[EJBTHREE-1010] Don't leak JBC exception classes to client
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java 2007-07-12 21:48:26 UTC (rev 64017)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/JBCCache.java 2007-07-12 21:50:40 UTC (rev 64018)
@@ -108,7 +108,7 @@
return cache.get( new Fqn( regionFqn, key ), ITEM );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -124,7 +124,7 @@
}
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -154,7 +154,7 @@
log.debug("ignoring write lock acquisition failure");
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
finally {
resume( tx );
@@ -195,7 +195,7 @@
}
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -204,7 +204,7 @@
cache.remove( regionFqn );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -226,7 +226,7 @@
throw e;
}
catch( Exception e ) {
- throw new CacheException( e );
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -260,7 +260,7 @@
return children == null ? 0 : children.size();
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -285,7 +285,7 @@
return result;
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -311,7 +311,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem activating region " + regionName, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
else
@@ -333,7 +333,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem activating region " + fqnString, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
else
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java 2007-07-12 21:48:26 UTC (rev 64017)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/OptimisticJBCCache.java 2007-07-12 21:50:40 UTC (rev 64018)
@@ -118,7 +118,7 @@
cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
}
catch ( Exception e ) {
- throw new CacheException( e );
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -140,7 +140,7 @@
cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -155,7 +155,7 @@
return cache.get( new Fqn( regionFqn, key ), ITEM, option );
}
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);
}
}
@@ -176,7 +176,7 @@
cache.put( new Fqn( regionFqn, key ), ITEM, value, option );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -195,7 +195,7 @@
log.debug("ignoring write lock acquisition failure");
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -214,7 +214,7 @@
}
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -226,7 +226,7 @@
cache.remove( regionFqn, option );
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -244,7 +244,7 @@
}
}
catch( Exception e ) {
- throw new CacheException( e );
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -278,7 +278,7 @@
return children == null ? 0 : children.size();
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -303,7 +303,7 @@
return result;
}
catch (Exception e) {
- throw new CacheException(e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
@@ -329,7 +329,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem activating region " + regionName, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
else
@@ -351,7 +351,7 @@
}
catch (Exception e)
{
- throw new CacheException("Problem activating region " + fqnString, e);
+ throw SecondLevelCacheUtil.convertToHibernateException(e);
}
}
else
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java 2007-07-12 21:48:26 UTC (rev 64017)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/entity/SecondLevelCacheUtil.java 2007-07-12 21:50:40 UTC (rev 64018)
@@ -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