List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:org.jlibrary.core.http.client.HTTPRepositoryDelegate.java
public Document createDocument(Ticket ticket, DocumentProperties docProperties, InputStream content) throws RepositoryException, SecurityException { try {//w w w.ja v a2 s . c o m Document d = (Document) doRepositoryStreamedRequest("createDocument", new Object[] { ticket, docProperties }, Document.class, content); return d; } catch (RuntimeException e) { throw e; } catch (RepositoryException e) { if (e.getCause() != null) { if (e.getCause().getClass() == SecurityException.class) { throw (SecurityException) e.getCause(); } } throw e; } }
From source file:org.geoserver.gwc.GWCTest.java
@Test public void testLayerRemoved() throws Exception { mediator.layerRemoved("someLayer"); verify(storageBroker, times(1)).delete(eq("someLayer")); doThrow(new StorageException("fake")).when(storageBroker).delete(eq("anotherLayer")); try {//from w w w .j a v a 2 s . co m mediator.layerRemoved("anotherLayer"); fail("Expected RTE"); } catch (RuntimeException e) { assertTrue(e.getCause() instanceof StorageException); } }
From source file:org.geoserver.gwc.GWCTest.java
@Test public void testLayerRenamed() throws Exception { mediator.layerRenamed("old", "new"); verify(storageBroker, times(1)).rename(eq("old"), eq("new")); doThrow(new StorageException("target directory already exists")).when(storageBroker).rename(eq("old"), eq("new")); try {// w ww .ja v a 2 s . co m mediator.layerRenamed("old", "new"); fail("Expected RTE"); } catch (RuntimeException e) { assertTrue(e.getCause() instanceof StorageException); } }
From source file:org.geoserver.gwc.GWCTest.java
@Test public void testLayerAdded() throws Exception { when(diskQuotaMonitor.isEnabled()).thenReturn(false); mediator.layerAdded("someLayer"); verify(quotaStore, never()).createLayer(anyString()); when(diskQuotaMonitor.isEnabled()).thenReturn(true); mediator.layerAdded("someLayer"); verify(quotaStore, times(1)).createLayer(eq("someLayer")); doThrow(new InterruptedException("fake")).when(quotaStore).createLayer(eq("someLayer")); try {//from w ww . j a va2 s . co m mediator.layerAdded("someLayer"); fail("Expected RTE"); } catch (RuntimeException e) { assertTrue(e.getCause() instanceof InterruptedException); } }
From source file:org.opendaylight.netvirt.elan.utils.ElanUtils.java
public static void addToListenableFutureIfTxException(RuntimeException exception, List<ListenableFuture<Void>> futures) { Throwable cause = exception.getCause(); if (cause != null && cause instanceof TransactionCommitFailedException) { futures.add(Futures.immediateFailedCheckedFuture((TransactionCommitFailedException) cause)); }/* ww w . j a va2 s .c o m*/ }
From source file:org.apache.pulsar.broker.service.BrokerService.java
/** * Create pending topic and on completion it picks the next one until processes all topics in * {@link #pendingTopicLoadingQueue}.<br/> * It also tries to acquire {@link #topicLoadRequestSemaphore} so throttle down newly incoming topics and release * permit if it was successful to acquire it. *///ww w. j a v a2 s . c om private void createPendingLoadTopic() { Pair<String, CompletableFuture<Topic>> pendingTopic = pendingTopicLoadingQueue.poll(); if (pendingTopic == null) { return; } final String topic = pendingTopic.getLeft(); try { checkTopicNsOwnership(topic); CompletableFuture<Topic> pendingFuture = pendingTopic.getRight(); final Semaphore topicLoadSemaphore = topicLoadRequestSemaphore.get(); final boolean acquiredPermit = topicLoadSemaphore.tryAcquire(); createPersistentTopic(topic, pendingFuture); pendingFuture.handle((persistentTopic, ex) -> { // release permit and process next pending topic if (acquiredPermit) { topicLoadSemaphore.release(); } createPendingLoadTopic(); return null; }); } catch (RuntimeException re) { log.error("Failed to create pending topic {} {}", topic, re); pendingTopic.getRight().completeExceptionally(re.getCause()); // schedule to process next pending topic inactivityMonitor.schedule(() -> createPendingLoadTopic(), 100, TimeUnit.MILLISECONDS); } }
From source file:org.jlibrary.core.http.client.HTTPRepositoryDelegate.java
public String getJLibraryAPIVersion() throws UnknownMethodException { try {/* w w w . j a v a2s. c o m*/ String version = (String) doRepositoryRequest("getJLibraryAPIVersion", new Object[] {}, String.class); return version; } catch (RuntimeException e) { throw e; } catch (RepositoryException e) { // TODO: another way? if (e.getCause() != null && (e.getCause() instanceof NoSuchMethodException)) { throw new UnknownMethodException(e.getCause()); } throw new RuntimeException(e); } }
From source file:org.apache.phoenix.jdbc.PhoenixResultSet.java
@Override public boolean next() throws SQLException { checkOpen();//from w w w. ja va 2s . c o m try { if (!firstRecordRead) { firstRecordRead = true; overAllQueryMetrics.startResultSetWatch(); } currentRow = scanner.next(); rowProjector.reset(); } catch (RuntimeException e) { // FIXME: Expression.evaluate does not throw SQLException // so this will unwrap throws from that. if (e.getCause() instanceof SQLException) { throw (SQLException) e.getCause(); } throw e; } if (currentRow == null) { overAllQueryMetrics.endQuery(); overAllQueryMetrics.stopResultSetWatch(); } return currentRow != null; }
From source file:com.github.jackygurui.vertxredissonrepository.repository.Impl.RedisRepositoryImpl.java
private void searchIndexByPositionBlocking(String fieldName, String indexName, Integer start, Integer stop, AsyncResultHandler<List<String>> resultHandler) { redissonOther.getScoredSortedSet(getScoredSortedIndexKey(fieldName, indexName), StringCodec.INSTANCE) .valueRangeAsync(start, stop).addListener(future -> { Collection<String> res = (Collection<String>) future.get(); try { ArrayList<String> ids = res.stream().map(r -> lookupIdFromIndex(r, fieldName, indexName)) .collect(Collectors.toCollection(ArrayList::new)); resultHandler//from ww w .j a v a 2s. c o m .handle(future.isSuccess() ? (future.get() != null ? Future.succeededFuture(ids) : Future.failedFuture( new RepositoryException("No search result returned"))) : Future.failedFuture(new RepositoryException(future.cause()))); if (future.isSuccess()) { logger.debug("[" + getStorageKey() + "] Search Index By Position Success. Records: " + ((Collection<String>) future.get()).size()); } else { logger.debug("[" + getStorageKey() + "] Search Index By Position Failure.", future.cause()); } } catch (RuntimeException e) { resultHandler.handle(Future.failedFuture(e.getCause())); logger.debug("[" + getStorageKey() + "] Search Index By Position Failure.", e); } }); }
From source file:com.github.jackygurui.vertxredissonrepository.repository.Impl.RedisRepositoryImpl.java
private void searchIndexByValueBlocking(String fieldName, String indexName, String min, String max, Integer offset, Integer limit, AsyncResultHandler<List<String>> resultHandler) { redissonOther.<String>getLexSortedSet(getScoredSortedIndexKey(fieldName, indexName)) .lexRangeAsync(min, true, max, true, offset, limit).addListener(future -> { Collection<String> res = (Collection<String>) future.get(); try { ArrayList<String> ids = res.stream().map(r -> lookupIdFromIndex(r, fieldName, indexName)) .collect(Collectors.toCollection(ArrayList::new)); resultHandler/* w w w .j a v a 2s.co m*/ .handle(future.isSuccess() ? (future.get() != null ? Future.succeededFuture(ids) : Future.failedFuture( new RepositoryException("No search result returned"))) : Future.failedFuture(new RepositoryException(future.cause()))); if (future.isSuccess()) { logger.debug("[" + getStorageKey() + "] Search Index By Value Success. Records: " + ((Collection<String>) future.get()).size()); } else { logger.debug("[" + getStorageKey() + "] Search Index By Value Failure.", future.cause()); } } catch (RuntimeException e) { resultHandler.handle(Future.failedFuture(e.getCause())); logger.debug("[" + getStorageKey() + "] Search Index By Value Failure.", e); } }); }