List of usage examples for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException
public UndeclaredThrowableException(Throwable undeclaredThrowable)
From source file:co.paralleluniverse.fibers.httpclient.FiberHttpClient.java
/** * {@inheritDoc}/*from w w w . ja va 2s .c o m*/ */ @Override @Suspendable public <T> T execute(HttpHost target, HttpRequest request, ResponseHandler<? extends T> responseHandler, HttpContext context) throws IOException, ClientProtocolException { final HttpResponse response = doExecute(target, request, context); final T result; try { result = responseHandler.handleResponse(response); } catch (final Exception t) { final HttpEntity entity = response.getEntity(); try { EntityUtils.consume(entity); } catch (final Exception t2) { // Log this exception. The original exception is more // important and will be thrown to the caller. this.log.warn("Error consuming content after an exception.", t2); } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof IOException) { throw (IOException) t; } throw new UndeclaredThrowableException(t); } // Handling the response was successful. Ensure that the content has // been fully consumed. final HttpEntity entity = response.getEntity(); EntityUtils.consume(entity); return result; }
From source file:org.apache.http.HC4.impl.client.CloseableHttpClient.java
/** * Executes a request using the default context and processes the * response using the given response handler. The content entity associated * with the response is fully consumed and the underlying connection is * released back to the connection manager automatically in all cases * relieving individual {@link ResponseHandler}s from having to manage * resource deallocation internally./*from www.j a va 2 s .c o m*/ * * @param target the target host for the request. * Implementations may accept {@code null} * if they can still determine a route, for example * to a default target or by inspecting the request. * @param request the request to execute * @param responseHandler the response handler * @param context the context to use for the execution, or * {@code null} to use the default context * * @return the response object as generated by the response handler. * @throws IOException in case of a problem or the connection was aborted * @throws ClientProtocolException in case of an http protocol error */ @Override public <T> T execute(final HttpHost target, final HttpRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException { Args.notNull(responseHandler, "Response handler"); final HttpResponse response = execute(target, request, context); final T result; try { result = responseHandler.handleResponse(response); } catch (final Exception t) { final HttpEntity entity = response.getEntity(); try { EntityUtils.consume(entity); } catch (final Exception t2) { // Log this exception. The original exception is more // important and will be thrown to the caller. this.log.warn("Error consuming content after an exception.", t2); } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof IOException) { throw (IOException) t; } throw new UndeclaredThrowableException(t); } // Handling the response was successful. Ensure that the content has // been fully consumed. final HttpEntity entity = response.getEntity(); EntityUtils.consume(entity); return result; }
From source file:com.epam.reportportal.apache.http.impl.client.CloseableHttpClient.java
/** * Executes a request using the default context and processes the * response using the given response handler. The content entity associated * with the response is fully consumed and the underlying connection is * released back to the connection manager automatically in all cases * relieving individual {@link ResponseHandler}s from having to manage * resource deallocation internally.// w w w . java 2 s . co m * * @param target the target host for the request. * Implementations may accept <code>null</code> * if they can still determine a route, for example * to a default target or by inspecting the request. * @param request the request to execute * @param responseHandler the response handler * @param context the context to use for the execution, or * <code>null</code> to use the default context * * @return the response object as generated by the response handler. * @throws IOException in case of a problem or the connection was aborted * @throws ClientProtocolException in case of an http protocol error */ public <T> T execute(final HttpHost target, final HttpRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException { Args.notNull(responseHandler, "Response handler"); final HttpResponse response = execute(target, request, context); final T result; try { result = responseHandler.handleResponse(response); } catch (final Exception t) { final HttpEntity entity = response.getEntity(); try { EntityUtils.consume(entity); } catch (final Exception t2) { // Log this exception. The original exception is more // important and will be thrown to the caller. this.log.warn("Error consuming content after an exception.", t2); } if (t instanceof RuntimeException) { throw (RuntimeException) t; } if (t instanceof IOException) { throw (IOException) t; } throw new UndeclaredThrowableException(t); } // Handling the response was successful. Ensure that the content has // been fully consumed. final HttpEntity entity = response.getEntity(); EntityUtils.consume(entity); return result; }
From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java
@SuppressWarnings({ "rawtypes", "unchecked" }) private JPanel createQuerySelectionPanel() { JPanel querySelectionPanel = new JPanel(); GridBagLayout gbl = new GridBagLayout(); querySelectionPanel.setLayout(gbl);/* www . j a va2 s . c o m*/ //The selectQueryCombo selectQueryLabel = new JLabel(resourceBundle.getString("title.selectQuery"), SwingConstants.LEADING); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(selectQueryLabel, c); querySelectionPanel.add(selectQueryLabel); //TODO: SwingBoost: localize this: selectQueryCombo = new JComboBox(new String[] { "loading queries..." }); selectQueryCombo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ev) { RegistryBrowser.setWaitCursor(); if (ev.getStateChange() == ItemEvent.DESELECTED) { return; } @SuppressWarnings("unused") String item = (String) ev.getItem(); int index = ((JComboBox) ev.getSource()).getSelectedIndex(); QueryType uiQueryType = queries.get(index); try { setQuery(uiQueryType); } catch (JAXRException e) { RegistryBrowser.setDefaultCursor(); throw new UndeclaredThrowableException(e); } RegistryBrowser.setDefaultCursor(); } }); c.gridx = 0; c.gridy = 1; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(selectQueryCombo, c); querySelectionPanel.add(selectQueryCombo); //The nameTextField queryNameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING); c.gridx = 0; c.gridy = 2; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(queryNameLabel, c); querySelectionPanel.add(queryNameLabel); queryNameText = new JTextField(); queryNameText.setEditable(false); c.gridx = 0; c.gridy = 3; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.0; c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(queryNameText, c); querySelectionPanel.add(queryNameText); //The description TextArea queryDescLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING); c.gridx = 0; c.gridy = 4; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(4, 4, 0, 4); gbl.setConstraints(queryDescLabel, c); querySelectionPanel.add(queryDescLabel); queryDescText = new JTextArea(4, 25); queryDescText.setLineWrap(true); queryDescText.setEditable(false); c.gridx = 0; c.gridy = 5; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(4, 4, 4, 4); gbl.setConstraints(queryDescText, c); querySelectionPanel.add(queryDescText); return querySelectionPanel; }
From source file:com.link_intersystems.lang.ContextAware.java
/** * Runs the {@link Runnable} in this {@link ContextAware}'s context (defined * by subclasses).//w w w . j ava 2s .c o m * * @param runnable * the runnable that should be run with this {@link ContextAware} * 's context (defined by subclasses). * @since 1.2.0.0 */ public void runInContext(Runnable runnable) { RunnableRunInContext runInContext = new RunnableRunInContext(runnable); try { thisContextProviderAdapter.provideContext(runInContext); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new UndeclaredThrowableException(e); } }
From source file:it.cnr.icar.eric.client.xml.registry.LifeCycleManagerImpl.java
LifeCycleManagerImpl(RegistryServiceImpl regService) { this.regService = regService; imFactory = InfomodelFactory.getInstance(); modifiedObjects = new HashSet<Object>(); lcmFac = bu.lcmFac;//w w w . j a va2 s .co m rsFac = bu.rsFac; rimFac = bu.rimFac; try { setCredentialInfo((regService.getConnection()).getCredentialInfo()); } catch (JAXRException e) { throw new UndeclaredThrowableException(e); } }
From source file:br.com.lucasisrael.regra.reflections.TratamentoReflections.java
/** * Handle the given reflection exception. Should only be called if no * checked exception is expected to be thrown by the target method. * <p>Throws the underlying RuntimeException or Error in case of an * InvocationTargetException with such a root cause. Throws an * IllegalStateException with an appropriate message else. * @param ex the reflection exception to handle *//*from w w w.j a v a 2s. c o m*/ public static void handleReflectionException(Exception ex) { if (ex instanceof NoSuchMethodException) { throw new IllegalStateException("Method not found: " + ex.getMessage()); } if (ex instanceof IllegalAccessException) { throw new IllegalStateException("Could not access method: " + ex.getMessage()); } if (ex instanceof InvocationTargetException) { handleInvocationTargetException((InvocationTargetException) ex); } if (ex instanceof RuntimeException) { throw (RuntimeException) ex; } throw new UndeclaredThrowableException(ex); }
From source file:com.ibm.jaql.lang.expr.xml.TypedXmlToJsonFn.java
/** * /*w w w . ja v a2 s . co m*/ */ @Override public void endElement(String uri, String localName, String name) throws SAXException { try { BufferedJsonRecord r = stack.pop(); int textEnd = text.length(); int textStart = lengths.pop(); JsonValue me = r; if (textStart < textEnd) { JsonString s = new JsonString(text.substring(textStart, textEnd)); text.setLength(textStart); if (r.size() == 0) { me = cast(s.toString()); } else if (!StringUtils.isBlank(s.toString())) { r.add(textName, cast(s.toString())); } } BufferedJsonRecord parent = stack.peek(); // uri is not empty, use namespace record as parent. if (uri != null && uri.length() > 0) { JsonString jUri = new JsonString(uri); BufferedJsonRecord ur = (BufferedJsonRecord) parent.get(jUri, null); if (ur == null) { ur = new BufferedJsonRecord(); parent.add(jUri, ur); } parent = ur; } JsonString jLocalName = new JsonString(localName); if (!parent.containsKey(jLocalName)) { parent.add(jLocalName, me); } else { JsonValue v = parent.get(jLocalName); SpilledJsonArray a; if (v instanceof SpilledJsonArray) { a = (SpilledJsonArray) v; } else { a = new SpilledJsonArray(); a.addCopy(v); parent.set(jLocalName, a); } a.addCopy(me); } } catch (IOException e) { throw new UndeclaredThrowableException(e); } }
From source file:it.cnr.icar.eric.common.BindingUtility.java
/** * Class Constructor. Protected and only used by getInstance() * *///from w w w. j av a2 s . c o m protected BindingUtility() { try { getJAXBContext(); rimFac = new org.oasis.ebxml.registry.bindings.rim.ObjectFactory(); rsFac = new org.oasis.ebxml.registry.bindings.rs.ObjectFactory(); lcmFac = new org.oasis.ebxml.registry.bindings.lcm.ObjectFactory(); queryFac = new org.oasis.ebxml.registry.bindings.query.ObjectFactory(); cmsFac = new org.oasis.ebxml.registry.bindings.cms.ObjectFactory(); //samlProtocolFac = new org.oasis.saml.bindings._20.protocol.ObjectFactory(); //samlAssertionFac = new org.oasis.saml.bindings._20.assertion.ObjectFactory(); } catch (JAXBException e) { throw new UndeclaredThrowableException(e); } }
From source file:com.ibm.jaql.lang.expr.xml.XmlToJsonFn.java
/** * /*w ww . j a v a 2 s. com*/ */ @Override public void endElement(String uri, String localName, String name) throws SAXException { try { BufferedJsonRecord r = stack.pop(); int textEnd = text.length(); int textStart = lengths.pop(); JsonValue me = r; if (textStart < textEnd) { JsonString s = new JsonString(text.substring(textStart, textEnd)); text.setLength(textStart); if (r.size() == 0) { me = s; } else if (!StringUtils.isBlank(s.toString())) { r.add(textName, s); } } BufferedJsonRecord parent = stack.peek(); // uri is not empty, use namespace record as parent. if (uri != null && uri.length() > 0) { JsonString jUri = new JsonString(uri); BufferedJsonRecord ur = (BufferedJsonRecord) parent.get(jUri, null); if (ur == null) { ur = new BufferedJsonRecord(); parent.add(jUri, ur); } parent = ur; } JsonString jLocalName = new JsonString(localName); if (!parent.containsKey(jLocalName)) { parent.add(jLocalName, me); } else { JsonValue v = parent.get(jLocalName); SpilledJsonArray a; if (v instanceof SpilledJsonArray) { a = (SpilledJsonArray) v; } else { a = new SpilledJsonArray(); a.addCopy(v); parent.set(jLocalName, a); } a.addCopy(me); } } catch (IOException e) { throw new UndeclaredThrowableException(e); } }