Skip to content

Commit

Permalink
Unknown hostnames correspond to reserved ones in RFC 2602 Reserved To…
Browse files Browse the repository at this point in the history
…p Level DNS Names (OpenFeign#2087)
  • Loading branch information
vitalijr2 authored Jun 19, 2023
1 parent e92364f commit ad167f5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
42 changes: 21 additions & 21 deletions core/src/test/java/feign/LoggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,23 +267,23 @@ public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{Level.NONE, Collections.emptyList()},
{Level.BASIC, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)")},
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)")},
{Level.HEADERS, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] Content-Length: 80",
"\\[SendsStuff#login\\] Content-Type: application/json",
"\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)")},
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)")},
{Level.FULL, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] Content-Length: 80",
"\\[SendsStuff#login\\] Content-Type: application/json",
"\\[SendsStuff#login\\] ",
"\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"\\}",
"\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)",
"(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: robofu.abc.*",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)",
"(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: non-exist.invalid.*",
"\\[SendsStuff#login\\] <--- END ERROR")}
});
}
Expand All @@ -304,7 +304,7 @@ public Retryer clone() {
return this;
}
})
.target(SendsStuff.class, "http://robofu.abc");
.target(SendsStuff.class, "http://non-exist.invalid");

thrown.expect(FeignException.class);

Expand All @@ -329,23 +329,23 @@ public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{Level.NONE, Collections.emptyList()},
{Level.BASIC, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://sna%fu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: sna%fu.abc \\([0-9]+ms\\)")},
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)")},
{Level.HEADERS, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://sna%fu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] Content-Length: 80",
"\\[SendsStuff#login\\] Content-Type: application/json",
"\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: sna%fu.abc \\([0-9]+ms\\)")},
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)")},
{Level.FULL, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://sna%fu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] Content-Length: 80",
"\\[SendsStuff#login\\] Content-Type: application/json",
"\\[SendsStuff#login\\] ",
"\\[SendsStuff#login\\] \\{\"customer_name\": \"netflix\", \"user_name\": \"denominator\", \"password\": \"password\"\\}",
"\\[SendsStuff#login\\] ---> END HTTP \\(80-byte body\\)",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: sna%fu.abc \\([0-9]+ms\\)",
"(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: sna%fu.abc.*",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)",
"(?s)\\[SendsStuff#login\\] java.net.UnknownHostException: non-exist.invalid.*",
"\\[SendsStuff#login\\] <--- END ERROR")}
});
}
Expand All @@ -366,7 +366,7 @@ public Retryer clone() {
return this;
}
})
.target(SendsStuff.class, "http://sna%25fu.abc");
.target(SendsStuff.class, "http://non-exist.invalid");

thrown.expect(FeignException.class);

Expand All @@ -390,11 +390,11 @@ public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][] {
{Level.NONE, Collections.emptyList()},
{Level.BASIC, Arrays.asList(
"\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)",
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)",
"\\[SendsStuff#login\\] ---> RETRYING",
"\\[SendsStuff#login\\] ---> POST http://robofu.abc/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: robofu.abc \\([0-9]+ms\\)")}
"\\[SendsStuff#login\\] ---> POST http://non-exist.invalid/ HTTP/1.1",
"\\[SendsStuff#login\\] <--- ERROR UnknownHostException: non-exist.invalid \\([0-9]+ms\\)")}
});
}

Expand Down Expand Up @@ -422,7 +422,7 @@ public Retryer clone() {
return this;
}
})
.target(SendsStuff.class, "http://robofu.abc");
.target(SendsStuff.class, "http://non-exist.invalid");

api.login("netflix", "denominator", "password");
}
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -421,11 +421,13 @@
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
Expand Down Expand Up @@ -531,6 +533,7 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
Expand Down Expand Up @@ -569,11 +572,13 @@
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>${maven-release-plugin.version}</version>
<configuration>
Expand Down

0 comments on commit ad167f5

Please sign in to comment.