Example usage for java.lang InterruptedException getCause

List of usage examples for java.lang InterruptedException getCause

Introduction

In this page you can find the example usage for java.lang InterruptedException getCause.

Prototype

public synchronized Throwable getCause() 

Source Link

Document

Returns the cause of this throwable or null if the cause is nonexistent or unknown.

Usage

From source file:org.onosproject.store.consistent.impl.DatabaseManager.java

private static <T> T complete(CompletableFuture<T> future) {
    try {/*w ww .ja  v a  2 s . c  o m*/
        return future.get(DATABASE_OPERATION_TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new ConsistentMapException.Interrupted();
    } catch (TimeoutException e) {
        throw new ConsistentMapException.Timeout();
    } catch (ExecutionException e) {
        throw new ConsistentMapException(e.getCause());
    }
}

From source file:savant.util.BackgroundWorker.java

@Override
public void done() {
    showProgress(1.0);/* ww  w  .j  a va  2  s. c  o m*/
    if (!isCancelled()) {
        try {
            showSuccess(get());
        } catch (InterruptedException x) {
            showFailure(x);
        } catch (ExecutionException x) {
            showFailure(x.getCause());
        }
    }
}

From source file:com.launchkey.example.springmvc.LaunchKeyAuthenticationProvider.java

@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
    String username = authentication.getName();

    try {//from   ww  w.j  a  v a2  s. co  m
        this.authManager.login(username);
        Boolean authorized = null;
        while (authorized == null) {
            Thread.sleep(100L);
            authorized = this.authManager.isAuthorized();
        }
        if (authorized == null) {
            throw new InsufficientAuthenticationException(
                    "The authentication request was not responded to in sufficient time");
        } else if (!authorized) {
            throw new InsufficientAuthenticationException("The authentication request was denied");
        }
    } catch (InterruptedException e) {
        throw new AuthenticationServiceException("Sleep error");
    } catch (AuthManager.AuthException e) {
        if (e.getCause() instanceof LaunchKeyException) {
            throw new BadCredentialsException("Authentication failure", e.getCause());
        }
    }

    return new UsernamePasswordAuthenticationToken(username, authentication.getCredentials(),
            new ArrayList<GrantedAuthority>());
}

From source file:org.apache.hadoop.hdfs.server.datanode.BlockPoolManager.java

synchronized void startAll() throws IOException {
    try {//w  ww.  j a va 2s .c  o m
        UserGroupInformation.getLoginUser().doAs(new PrivilegedExceptionAction<Object>() {
            @Override
            public Object run() throws Exception {
                for (BPOfferService bpos : offerServices) {
                    bpos.start();
                }
                return null;
            }
        });
    } catch (InterruptedException ex) {
        IOException ioe = new IOException();
        ioe.initCause(ex.getCause());
        throw ioe;
    }
}

From source file:org.usrz.libs.riak.async.AsyncJsonGenerator.java

@Override
public Body createBody() throws IOException {
    try {//from  www  .j  a  v a2  s. c  o  m
        return new ByteArrayBodyGenerator(future.get()).createBody();
    } catch (InterruptedException exception) {
        throw new IllegalStateException("Interrupted", exception);
    } catch (ExecutionException exception) {
        final Throwable cause = exception.getCause();
        if (cause instanceof Error)
            throw (Error) cause;
        if (cause instanceof IOException)
            throw (IOException) cause;
        if (cause instanceof RuntimeException)
            throw (RuntimeException) cause;
        throw new IOException("Exception generating content", cause);
    }
}

From source file:de.onyxbits.raccoon.appmgr.ExtractWorker.java

@Override
public void done() {
    try {//from   w w w.  jav  a 2s . c  o m
        BrowseAction.open(get().toURI());
    } catch (InterruptedException e) {
    } catch (ExecutionException e) {
        JOptionPane.showMessageDialog(null, e.getCause().getLocalizedMessage());
        e.printStackTrace();
    }
}

From source file:org.wso2.andes.kernel.distruptor.inbound.InboundSubscriptionEvent.java

public boolean waitForCompletion() throws AndesException, SubscriptionAlreadyExistsException {
    try {//  w  w w .j a  v a  2s. c  o  m
        return future.get();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (ExecutionException e) {
        if (e.getCause() instanceof SubscriptionAlreadyExistsException) {
            throw (SubscriptionAlreadyExistsException) e.getCause();
        } else {
            throw new AndesException("Error occurred while processing event '" + eventType
                    + "' for subscription id " + getSubscriptionID(), e);
        }
    }
    return false;
}

From source file:org.wso2.andes.kernel.disruptor.inbound.InboundSubscriptionSyncEvent.java

public boolean waitForCompletion() throws SubscriptionAlreadyExistsException {
    try {/*from   ww  w.j  a v  a 2s.c o m*/
        return future.get();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    } catch (ExecutionException e) {
        if (e.getCause() instanceof SubscriptionAlreadyExistsException) {
            throw (SubscriptionAlreadyExistsException) e.getCause();
        } else {
            // No point in throwing an exception here and disrupting the server. A warning is sufficient.
            log.warn("Error occurred while processing event '" + eventType + "' for subscriber "
                    + encodedSubscriptionEventInfo);
        }
    }
    return false;
}

From source file:com.subgraph.vega.internal.http.requests.HttpRequestEngine.java

@Override
public IHttpResponse sendRequest(HttpUriRequest request, HttpContext context) throws RequestEngineException {
    final HttpContext requestContext = (context == null) ? (new BasicHttpContext()) : (context);
    requestContext.setAttribute(ClientContext.COOKIE_STORE, config.getCookieStore());
    Future<IHttpResponse> future = executor
            .submit(new RequestTask(client, rateLimit, request, requestContext, config, htmlParser));
    try {//from   w w  w  .ja  v  a2  s .  co m
        return future.get();
    } catch (InterruptedException e) {
        logger.info("Request " + request.getURI() + " was interrupted before completion");
    } catch (ExecutionException e) {
        throw translateException(request, e.getCause());
    }
    return null;
}

From source file:org.ut.biolab.medsavant.client.util.MedSavantWorker.java

public void done() {
    if (this.progressTimer != null) {
        this.progressTimer.stop();
    }/* w  w w  .ja  v a  2s .  c  om*/
    showProgress(1.0);
    try {
        if (!swingWorker.isCancelled()) {
            showSuccess(swingWorker.get());
        } else {
            // Send the server one last checkProgress call so that server knows that we've cancelled.
            try {
                checkProgress();
            } catch (Exception ex) {
                LOG.info("Ignoring exception thrown while cancelling.", ex);
            }
            throw new InterruptedException();
        }
    } catch (InterruptedException x) {
        showFailure(x);
    } catch (ExecutionException x) {
        showFailure(x.getCause());
    } finally {
        // Succeed or fail, we want to remove the worker from our page.
        ThreadController.getInstance().removeWorker(this.pageName, this);
    }
}