List of usage examples for java.lang.reflect UndeclaredThrowableException UndeclaredThrowableException
public UndeclaredThrowableException(Throwable undeclaredThrowable)
From source file:org.apache.http.impl.client.AbstractStatisticsGatheringHttpClient.java
public <T> T execute(final HttpHost target, final HttpRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException { if (responseHandler == null) { throw new IllegalArgumentException("Response handler must not be null."); }// w ww .ja v a 2s. c o m HttpResponse response = execute(target, request, context); T result; try { result = responseHandler.handleResponse(response); } catch (Throwable t) { HttpEntity entity = response.getEntity(); try { EntityUtils.consume(entity); } catch (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 Error) { throw (Error) t; } 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. HttpEntity entity = response.getEntity(); EntityUtils.consume(entity); return result; }
From source file:org.jitsi.videobridge.Conference.java
/** * Returns, the <tt>TransportManager</tt> instance for the channel-bundle * with ID <tt>channelBundleId</tt>. If no instance exists and * <tt>create</tt> is <tt>true</tt>, one will be created. * * @param channelBundleId the ID of the channel-bundle for which to return * the <tt>TransportManager</tt>. * @param create whether to create a new instance, if one doesn't exist. * @return the <tt>TransportManager</tt> instance for the channel-bundle * with ID <tt>channelBundleId</tt>. *//*www.j av a2s.com*/ IceUdpTransportManager getTransportManager(String channelBundleId, boolean create) { IceUdpTransportManager transportManager; synchronized (transportManagers) { transportManager = transportManagers.get(channelBundleId); if (transportManager == null && create && !isExpired()) { try { //FIXME: the initiator is hard-coded // We assume rtcp-mux when bundle is used, so we make only // one component. transportManager = new IceUdpTransportManager(this, true, 1); } catch (IOException ioe) { throw new UndeclaredThrowableException(ioe); } transportManagers.put(channelBundleId, transportManager); } } return transportManager; }
From source file:org.apache.http2.impl.client.AbstractHttpClient.java
@Override public <T> T execute(final HttpHost target, final HttpRequest request, final ResponseHandler<? extends T> responseHandler, final HttpContext context) throws IOException, ClientProtocolException { if (responseHandler == null) { throw new IllegalArgumentException("Response handler must not be null."); }/* ww w . ja v a 2s. c om*/ HttpResponse response = execute(target, request, context); T result; try { result = responseHandler.handleResponse(response); } catch (Exception t) { HttpEntity entity = response.getEntity(); try { EntityUtils.consume(entity); } catch (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. HttpEntity entity = response.getEntity(); EntityUtils.consume(entity); return result; }
From source file:com.buaa.cfs.security.UserGroupInformation.java
/** * Run the given action as the user, potentially throwing an exception. * * @param <T> the return type of the run method * @param action the method to execute/* w w w . j av a 2 s.co m*/ * * @return the value from the run method * * @throws IOException if the action throws an IOException * @throws Error if the action throws an Error * @throws RuntimeException if the action throws a RuntimeException * @throws InterruptedException if the action throws an InterruptedException * @throws UndeclaredThrowableException if the action throws something else */ public <T> T doAs(PrivilegedExceptionAction<T> action) throws IOException, InterruptedException { try { logPrivilegedAction(subject, action); return Subject.doAs(subject, action); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (LOG.isDebugEnabled()) { LOG.debug("PrivilegedActionException as:" + this + " cause:" + cause); } if (cause instanceof IOException) { throw (IOException) cause; } else if (cause instanceof Error) { throw (Error) cause; } else if (cause instanceof RuntimeException) { throw (RuntimeException) cause; } else if (cause instanceof InterruptedException) { throw (InterruptedException) cause; } else { throw new UndeclaredThrowableException(cause); } } }