com.trendmicro.grid.acl.l0.util
Class ExceptionsUtil

java.lang.Object
  extended by com.trendmicro.grid.acl.l0.util.ExceptionsUtil

public final class ExceptionsUtil
extends Object

Is a utility class that offers methods to analyze exception chains in the context of 'ws-server'.

Author:
Juergen_Kellerer, 2012-02-14

Field Summary
static Set<String> CONCURRENT_ACCESS_CAUSES
          Lists all exception class names that may be thrown when a concurrent access caused the failure of writing into the database.
static Set<String> INVALID_DB_STATE_CAUSES
          Lists all exception class names that may be thrown when a the DB connection is within an invalid state (e.g.
 
Method Summary
static boolean isCausedByInvalidDbState(Throwable throwable)
          Returns true if the given throwable was caused by an invalid db connection state.
static boolean isOrContainsCause(Throwable throwable, Collection<String> classNames)
          Returns true if the throwable or one if its causes matches the given classNames.
static boolean isOrContainsCause(Throwable throwable, String... classNames)
          Returns true if the throwable or one if its causes matches the given classNames.
static boolean isPossiblyCausedByConcurrentAccess(Throwable throwable)
          Returns true if the given throwable could possibly been caused by a concurrent modification inside the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONCURRENT_ACCESS_CAUSES

public static final Set<String> CONCURRENT_ACCESS_CAUSES
Lists all exception class names that may be thrown when a concurrent access caused the failure of writing into the database.

Internal write-retry and exclusive locking may be triggered in the event of catching one of the exceptions listed below, before reporting the error back to the caller.


INVALID_DB_STATE_CAUSES

public static final Set<String> INVALID_DB_STATE_CAUSES
Lists all exception class names that may be thrown when a the DB connection is within an invalid state (e.g. a connection problem).

Note: Do not specify general SQL errors here as they do not uniquely identify a bad DB state.

Method Detail

isPossiblyCausedByConcurrentAccess

public static boolean isPossiblyCausedByConcurrentAccess(Throwable throwable)
Returns true if the given throwable could possibly been caused by a concurrent modification inside the database.

Parameters:
throwable - the throwable to test.
Returns:
true if the given throwable could possibly been caused by a concurrent modification inside the database.

isCausedByInvalidDbState

public static boolean isCausedByInvalidDbState(Throwable throwable)
Returns true if the given throwable was caused by an invalid db connection state.

Parameters:
throwable - the throwable to test.
Returns:
true if the given throwable was caused by an invalid db connection state

isOrContainsCause

public static boolean isOrContainsCause(Throwable throwable,
                                        String... classNames)
Returns true if the throwable or one if its causes matches the given classNames.

Parameters:
throwable - the throwable to test.
classNames - the names to of the expected exceptions.
Returns:
true if the throwable or one if its causes matches the given classNames.

isOrContainsCause

public static boolean isOrContainsCause(Throwable throwable,
                                        Collection<String> classNames)
Returns true if the throwable or one if its causes matches the given classNames.

Parameters:
throwable - the throwable to test.
classNames - the names to of the expected exceptions.
Returns:
true if the throwable or one if its causes matches the given classNames.