List of usage examples for java.lang IllegalStateException getCause
public synchronized Throwable getCause()
From source file:co.runrightfast.vertx.core.RunRightFastVerticle.java
/** * An IllegalStateException is thrown if a codec is already registered with the same name. Ignore the exception. * * @param <REQ>//from w ww .j a va 2 s . com * @param <RESP> * @param config */ private <REQ extends Message, RESP extends Message> void registerMessageCodecs( final MessageConsumerConfig<REQ, RESP> config) { final EventBus eventBus = vertx.eventBus(); try { final MessageCodec codec = new ProtobufMessageCodec( config.getAddressMessageMapping().getRequestDefaultInstance()); eventBus.registerDefaultCodec(config.getAddressMessageMapping().getRequestDefaultInstance().getClass(), codec); } catch (final IllegalStateException e) { log.logp(FINE, CLASS_NAME, "registerMessageCodecs", "failed to register codec for request message", e.getCause()); } config.getAddressMessageMapping().getResponseDefaultInstance().ifPresent(responseDefaultInstance -> { try { // TODO: Investigate why Optional type is lost - forced to cast responseDefaultInstance to Message final MessageCodec codec = new ProtobufMessageCodec((Message) responseDefaultInstance); eventBus.registerDefaultCodec(responseDefaultInstance.getClass(), codec); } catch (final IllegalStateException e) { log.logp(FINE, CLASS_NAME, "registerMessageCodecs", "failed to register codec for response message", e.getCause()); } }); }
From source file:co.paralleluniverse.fibers.httpclient.FiberHttpClient.java
@Override @Suspendable//from w w w .j a v a2 s . com protected final CloseableHttpResponse doExecute(final HttpHost target, final HttpRequest request, final HttpContext context) throws IOException, ClientProtocolException { try { for (int executionCount = 0;; executionCount++) { try { final HttpResponse response = new AsyncHttpReq() { @Override protected void requestAsync() { client.execute(target, request, context, this); } }.run(); return new CloseableHttpResponseWrapper(response); } catch (IOException ex) { if (httpRequestRetryHandler != null && httpRequestRetryHandler.retryRequest(ex, executionCount, context)) { if (this.log.isInfoEnabled()) { this.log.info("I/O exception (" + ex.getClass().getName() + ") caught when processing request: " + ex.getMessage()); } if (this.log.isDebugEnabled()) { this.log.debug(ex.getMessage(), ex); } this.log.info("Retrying request"); } else throw ex; } } } catch (SuspendExecution e) { throw new AssertionError(); } catch (IllegalStateException ise) { if (ioreactor != null) { final List<ExceptionEvent> events = ioreactor.getAuditLog(); if (events != null) { for (ExceptionEvent event : events) { final StringBuilder msg = new StringBuilder(); msg.append("Apache Async HTTP Client I/O Reactor exception timestamp: "); msg.append(event.getTimestamp()); if (event.getCause() != null) { msg.append(", cause stacktrace:\n"); final StringWriter sw = new StringWriter(); final PrintWriter pw = new PrintWriter(sw); ise.getCause().printStackTrace(pw); msg.append(sw.toString()); } this.log.fatal(msg.toString()); } } } throw ise; } }
From source file:org.opendaylight.vtn.manager.internal.util.vnode.VTNMacMapStatusTest.java
/** * Test case for {@link VTNMacMapStatus#VTNMacMapStatus()} and * {@link VTNMacMapStatus#VTNMacMapStatus(MacMapStatus)}. *///from www. j a va2 s . com @Test public void testConstructor() { // Test case for an empty instance. VTNMacMapStatus vmst = new VTNMacMapStatus(); MacMapStatus empty = new MacMapStatusBuilder().build(); assertEquals(empty, vmst.toMacMapStatus()); assertFalse(vmst.isDirty()); vmst = new VTNMacMapStatus(null); assertEquals(empty, vmst.toMacMapStatus()); assertFalse(vmst.isDirty()); vmst = new VTNMacMapStatus(empty); assertEquals(empty, vmst.toMacMapStatus()); assertFalse(vmst.isDirty()); HostMap hostMap = new HostMap(); MacVlan[] hosts = { new MacVlan(0x001122334455L, 0), new MacVlan(0xfeffabcdef00L, 0), new MacVlan(0xfeffabcdef05L, 1), new MacVlan(0xfeffabcdef0aL, 100), new MacVlan(0xfeffabcdefffL, 123), new MacVlan(0x000000000001L, 4094), new MacVlan(0x00000000000aL, 4094), new MacVlan(0xfc927ace41d7L, 4095), }; List<MappedHost> mhosts = new ArrayList<>(); for (MacVlan mv : hosts) { SalPort sport = getPort(); hostMap.put(mv, sport); MappedHost mhost = new MappedHostBuilder().setMacAddress(mv.getMacAddress()) .setPortId(sport.getNodeConnectorId()).setVlanId(new VlanId(mv.getVlanId())).build(); mhosts.add(mhost); MacMapStatus mst = new MacMapStatusBuilder().setMappedHost(mhosts).build(); vmst = new VTNMacMapStatus(mst); hostMap.verify(vmst.toMacMapStatus()); // Add one more host at the same port. long mac = mv.getAddress(); MacVlan newMv = new MacVlan(mac + 1L, mv.getVlanId()); hostMap.put(newMv, sport); mhost = new MappedHostBuilder().setMacAddress(newMv.getMacAddress()) .setPortId(sport.getNodeConnectorId()).setVlanId(new VlanId(newMv.getVlanId())).build(); mhosts.add(mhost); mst = new MacMapStatusBuilder().setMappedHost(mhosts).build(); vmst = new VTNMacMapStatus(mst); hostMap.verify(vmst.toMacMapStatus()); } // Test case for invalid mac-map-status. MappedHost mhost = new MappedHostBuilder().build(); mhosts = Collections.singletonList(mhost); MacMapStatus mst = new MacMapStatusBuilder().setMappedHost(mhosts).build(); try { new VTNMacMapStatus(mst); unexpected(); } catch (IllegalStateException e) { Throwable cause = e.getCause(); assertEquals(NullPointerException.class, cause.getClass()); String msg = "Unable to cache mac-map-status: " + cause.getMessage(); assertEquals(msg, e.getMessage()); } }