List of usage examples for java.lang RuntimeException getCause
public synchronized Throwable getCause()
From source file:org.apache.tuscany.sca.binding.jsonrpc.provider.JsonRpcServlet.java
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if ("smd".equals(request.getQueryString())) { handleSMDRequest(request, response); return;// w w w . j a v a2 s. c o m } try { handleJsonRpcInvocation(request, response); } catch (RuntimeException re) { if (re.getCause() instanceof javax.security.auth.login.LoginException) { response.setHeader("WWW-Authenticate", "BASIC realm=\"" + "ldap-realm" + "\""); response.sendError(HttpServletResponse.SC_UNAUTHORIZED); } else { throw re; } } }
From source file:de.lemo.apps.restws.client.InitialisationImpl.java
@Override public JSONObject taskResult(String taskId) { JSONObject json = new JSONObject(); Response taskResult = null;//from w ww . j a va 2 s .c om try { taskResult = taskManager.taskResult(taskId); } catch (RuntimeException e) { if (!e.getCause().getClass().equals(ConnectionPoolTimeoutException.class)) { // ignore ConnectionPoolTimeoutException, rethrow anything else //throw e; } } int status = (taskResult == null) ? HttpStatus.SC_GATEWAY_TIMEOUT : taskResult.getStatus(); if (status == HttpStatus.SC_INTERNAL_SERVER_ERROR) { // DMS error (maybe a processing timeout) json.put("status", HttpStatus.SC_BAD_GATEWAY); } else { json.put("status", status); } if (status == HttpStatus.SC_OK) { @SuppressWarnings("unchecked") ClientResponse<String> clientResponse = (ClientResponse<String>) taskResult; String analysisResult = clientResponse.getEntity(String.class); json.put("bideResult", new JSONObject(analysisResult)); } return json; }
From source file:org.grouplens.lenskit.eval.graph.GraphDumper.java
/** * Process a node.//from w ww . ja va2 s . co m * * @param node The node to process * @return The node's target descriptor (ID, possibly with port). */ String process(DAGNode<Component, Dependency> node) throws IOException { Preconditions.checkNotNull(node, "node must not be null"); if (nodeTargets.isEmpty()) { throw new IllegalStateException("root node has not been set"); } String id = nodeIds.get(node); String tgt; if (id == null) { id = "N" + nodeIds.size(); nodeIds.put(node, id); Component csat = node.getLabel(); assert csat != null; Satisfaction sat = csat.getSatisfaction(); try { tgt = sat.visit(new Visitor(node, id)); } catch (RuntimeException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { throw e; } } Preconditions.checkNotNull(tgt, "the returned target was null"); nodeTargets.put(id, tgt); } else { tgt = nodeTargets.get(id); if (tgt == null) { // tentatively use the node ID, we might remap it later tgt = id; } } return tgt; }
From source file:org.apache.james.mailrepository.file.FileMailRepository.java
@Override public Mail retrieve(String key) throws MessagingException { try {/*from w ww . ja va2s .c o m*/ Mail mc; try { mc = (Mail) objectRepository.get(key); } catch (RuntimeException re) { StringBuilder exceptionBuffer = new StringBuilder(128); if (re.getCause() instanceof Error) { exceptionBuffer.append("Error when retrieving mail, not deleting: ").append(re.toString()); } else { exceptionBuffer.append("Exception retrieving mail: ").append(re.toString()) .append(", so we're deleting it."); remove(key); } final String errorMessage = exceptionBuffer.toString(); getLogger().warn(errorMessage); getLogger().debug(errorMessage, re); return null; } MimeMessageStreamRepositorySource source = new MimeMessageStreamRepositorySource(streamRepository, destination, key); mc.setMessage(new MimeMessageCopyOnWriteProxy(source)); return mc; } catch (Exception me) { getLogger().error("Exception retrieving mail: " + me); throw new MessagingException("Exception while retrieving mail: " + me.getMessage(), me); } }
From source file:com.rackspacecloud.blueflood.io.serializers.SerializationTest.java
@Test(expected = SerializationException.class) public void testSerializeStringFails() throws Throwable { try {/*from w w w . j a v a 2 s .c o m*/ NumericSerializer.serializerFor(String.class).toByteBuffer("words"); } catch (RuntimeException e) { throw e.getCause(); } }
From source file:com.rackspacecloud.blueflood.io.serializers.SerializationTest.java
@Test(expected = SerializationException.class) public void testVersion2FullDeserializeBadType() throws Throwable { byte[] buf = new byte[] { 0, 2 }; try {/* www. j av a2s.c o m*/ NumericSerializer.serializerFor(Object.class).fromByteBuffer(ByteBuffer.wrap(buf)); } catch (RuntimeException e) { throw e.getCause(); } }
From source file:org.apache.juddi.v3.client.mapping.UDDIServiceCache.java
public void publishAndRegisterHttpCallbackEndpoint() throws BindException { if (clerk != null && listenerEndpoint == null) { try {/*w ww . j a va 2 s .co m*/ listenerServiceUrl = new URL(urlLocalizer.rewrite(new URL(DEFAULT_SUBSCRIPTION_LISTENER_URL))); WSDL2UDDI wsdl2UDDI = new WSDL2UDDI(clerk, urlLocalizer, properties); Definition wsdlDefinition = new ReadWSDL() .readWSDL("org/apache/juddi/v3/client/mapping/UDDIClientSubscriptionListener.wsdl"); String bindingKey = wsdl2UDDI .registerBusinessService(SUBSCRIPTION_LISTENER_SERVICE_NAME, SUBSCRIPTION_LISTENER_PORT_NAME, listenerServiceUrl, wsdlDefinition) .getBindingKey(); UDDISubscriptionListenerPortType subscriptionListener = new UDDIClientSubscriptionListenerImpl( bindingKey, this); log.info("Bringing up a UDDIClientSubscriptionListenerImpl on Endpoint " + listenerServiceUrl.toExternalForm()); listenerEndpoint = Endpoint.create(subscriptionListener); listenerEndpoint.publish(listenerServiceUrl.toExternalForm()); log.info("Registering a CallbackSubscription to this endpoint using bindingKey " + bindingKey); registerSubscription(bindingKey); } catch (RuntimeException t) { listenerEndpoint = null; if (t.getCause() instanceof BindException) { throw new BindException(t.getCause().getMessage()); } else { throw t; } } catch (Exception e) { log.error("Cannot publish or register the CallbackEndpoint " + e.getMessage(), e); } } }
From source file:com.rackspacecloud.blueflood.io.serializers.SerializationTest.java
@Test(expected = UnexpectedStringSerializationException.class) public void testDeserializeStringDoesNotFail() throws Throwable { // this is what a string looked like previously. try {/*from www . ja v a2s . c o m*/ String serialized = "AHMWVGhpcyBpcyBhIHRlc3Qgc3RyaW5nLg=="; ByteBuffer bb = ByteBuffer.wrap(Base64.decodeBase64(serialized.getBytes())); NumericSerializer.serializerFor(SimpleNumber.class).fromByteBuffer(bb); } catch (RuntimeException ex) { throw ex.getCause(); } }
From source file:com.rackspacecloud.blueflood.io.serializers.SerializationTest.java
@Test(expected = SerializationException.class) public void testCannotRoundtripBytes() throws Throwable { try {// w w w.ja v a 2 s . c om byte[] expected = new byte[] { 1, 2, 3, 4, 5 }; AbstractSerializer ser = NumericSerializer.serializerFor(SimpleNumber.class); byte[] actual = (byte[]) ser.fromByteBuffer(ser.toByteBuffer(expected)); Assert.assertArrayEquals(expected, actual); } catch (RuntimeException ex) { throw ex.getCause(); } }
From source file:com.rackspacecloud.blueflood.io.serializers.SerializationTest.java
@Test(expected = SerializationException.class) public void testCannotRoundtripStringWithNullType() throws Throwable { try {/* www . j a v a 2 s. c om*/ String expected = "this is a string"; ColumnFamily<Locator, Long> CF = null; ByteBuffer bb = NumericSerializer.serializerFor((Class) null).toByteBuffer(expected); String actual = (String) NumericSerializer.serializerFor((Class) null).fromByteBuffer(bb); Assert.assertEquals(expected, actual); } catch (RuntimeException ex) { throw ex.getCause(); } }