|
Summary: The two main exceptions thrown for cache problems: EntryVersionConflictException and CacheTimeoutException.
Overviewcom.j_spaces.core.client.CacheException is a runtime exception class. This exception is thrown when any kind of cache-related exception occurs. It is mostly used to wrap JavaSpaces exceptions, such as RemoteException or TransactionException. This class extends the RuntimeException, since the IMap implements java.util.Map methods that don't throw exceptions. EntryVersionConflictExceptionConcurrent updates on the same data-instance from multiple cache proxies may create a situation in which several clients attempt to update an old entry version. To avoid such situations, the cache throws a CacheException with EntryVersionConflictException when calling the IMap.put method. This exception can be retrieved from the generic CacheException in the following manner: boolean completed = false; while (!completed) { try { cache.put("key", value2); completed = true; System.out.println("updated key OK!"); } catch (CacheException e) { if (e.getCause() instanceof EntryVersionConflictException) { System.out.println(e.getCause().getMessage()); System.out.println("Reading key again!"); value2 = (MyData) cache.get("key"); } } } CacheTimeoutExceptionThe CacheTimeoutException extends the CacheException. This exception is thrown when one client is trying to update an Entry which is already blocked by another client, and the wait time has expired. If so, try to call the IMap.put method again. You can also change the default timeout using the IMap.setWaitForResponse() method. The CacheTimeoutException is thrown by: get(), remove(), put() and putAll() operations. |
(works on Firefox 2 and Internet Explorer 7)