Skip to content

Commit 2f368e9

Browse files
authored
GH-1773: Treat 410 Gone as 404 Not Found (#1774)
Fixes #1773
1 parent 419deb4 commit 2f368e9

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

maven-resolver-transport-http/src/main/java/org/eclipse/aether/transport/http/HttpTransporter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,11 @@ private URI resolve(TransportTask task) {
423423

424424
@Override
425425
public int classify(Throwable error) {
426-
if (error instanceof HttpResponseException
427-
&& ((HttpResponseException) error).getStatusCode() == HttpStatus.SC_NOT_FOUND) {
428-
return ERROR_NOT_FOUND;
426+
if (error instanceof HttpResponseException) {
427+
int statusCode = ((HttpResponseException) error).getStatusCode();
428+
if (statusCode == HttpStatus.SC_NOT_FOUND || statusCode == HttpStatus.SC_GONE) {
429+
return ERROR_NOT_FOUND;
430+
}
429431
}
430432
return ERROR_OTHER;
431433
}

maven-resolver-transport-http/src/test/java/org/eclipse/aether/transport/http/HttpTransporterTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public void testClassify() {
146146
assertEquals(Transporter.ERROR_OTHER, transporter.classify(new FileNotFoundException()));
147147
assertEquals(Transporter.ERROR_OTHER, transporter.classify(new HttpResponseException(403, "Forbidden")));
148148
assertEquals(Transporter.ERROR_NOT_FOUND, transporter.classify(new HttpResponseException(404, "Not Found")));
149+
assertEquals(Transporter.ERROR_NOT_FOUND, transporter.classify(new HttpResponseException(410, "Gone")));
149150
}
150151

151152
@Test

0 commit comments

Comments
 (0)