From 0bf92734217080e255d70c9edbb06f1b2ffbafad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 11 Jan 2025 11:44:59 +0100 Subject: [PATCH] Report timeout exceptions with own code --- .../p2maven/transport/TychoRepositoryTransport.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java index a649b0c89f..ac3596d85e 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/TychoRepositoryTransport.java @@ -20,6 +20,7 @@ import java.io.OutputStream; import java.net.URI; import java.net.URLConnection; +import java.net.http.HttpTimeoutException; import java.nio.file.Files; import java.nio.file.Path; import java.text.NumberFormat; @@ -45,6 +46,7 @@ import org.eclipse.equinox.internal.p2.repository.DownloadStatus; import org.eclipse.equinox.internal.provisional.p2.repository.IStateful; import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.core.ProvisionException; import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; import org.eclipse.tycho.transport.ArtifactDownloadProvider; @@ -123,8 +125,14 @@ public IStatus downloadArtifact(URI source, OutputStream target, IArtifactDescri } return reportStatus(downloadStatus, target); } catch (AuthenticationFailedException e) { - return Status.error("authentication failed for " + source, e); + return reportStatus(Status.error("authentication failed for " + source, e), target); } catch (IOException e) { + if (e instanceof HttpTimeoutException) { + return reportStatus(new Status(IStatus.ERROR, + TychoRepositoryTransport.class, + ProvisionException.REPOSITORY_FAILED_READ, + "download from " + source + " timed out", e), target); + } return reportStatus(Status.error("download from " + source + " failed", e), target); } catch (CoreException e) { return reportStatus(e.getStatus(), target);