|
36 | 36 | import java.util.Collections;
|
37 | 37 | import java.util.List;
|
38 | 38 | import java.util.Map;
|
| 39 | +import java.util.concurrent.CancellationException; |
39 | 40 | import java.util.concurrent.CompletableFuture;
|
| 41 | +import java.util.concurrent.ExecutionException; |
40 | 42 | import java.util.concurrent.TimeUnit;
|
41 | 43 | import java.util.zip.GZIPInputStream;
|
42 | 44 |
|
@@ -1006,11 +1008,26 @@ private IStatus performConnect(IProgressMonitor monitor) {
|
1006 | 1008 | int ticks = 1;
|
1007 | 1009 | monitor.beginTask(getRemoteFileURL().toString() + Messages.HttpClientRetrieveFileTransfer_CONNECTING_TASK_NAME, ticks);
|
1008 | 1010 | try {
|
1009 |
| - if (monitor.isCanceled()) |
1010 |
| - throw newUserCancelledException(); |
| 1011 | + if (monitor.isCanceled()) { |
| 1012 | + setDoneCanceled(); |
| 1013 | + return Status.CANCEL_STATUS; |
| 1014 | + } |
1011 | 1015 | httpResponse = httpClient.sendAsync(httpRequest, BodyHandlers.ofInputStream());
|
1012 | 1016 | responseCode = httpResponse.get(getConnectTimeout(),TimeUnit.MILLISECONDS).statusCode();
|
1013 |
| - } catch (final Exception e) { |
| 1017 | + } catch (InterruptedException e) { |
| 1018 | + Thread.currentThread().interrupt(); |
| 1019 | + setDoneCanceled(); |
| 1020 | + return Status.CANCEL_STATUS; |
| 1021 | + } catch (CancellationException e) { |
| 1022 | + setDoneCanceled(); |
| 1023 | + return Status.CANCEL_STATUS; |
| 1024 | + } catch (Exception e) { |
| 1025 | + if (e instanceof ExecutionException) { |
| 1026 | + Throwable cause = ((ExecutionException) e).getCause(); |
| 1027 | + if (cause instanceof Exception) { |
| 1028 | + e = (Exception) cause; |
| 1029 | + } |
| 1030 | + } |
1014 | 1031 | Trace.catching(Activator.PLUGIN_ID, DebugOptions.EXCEPTIONS_CATCHING, this.getClass(), "performConnect", e); //$NON-NLS-1$
|
1015 | 1032 | if (!isDone()) {
|
1016 | 1033 | setDoneException(e);
|
|
0 commit comments