-
Notifications
You must be signed in to change notification settings - Fork 84
Conversation
…ream host and port pair
@@ -78,7 +78,7 @@ public static void setupEthFirewall() throws IOException, CipherException { | |||
httpServerOptions.setPort(serverSocket.getLocalPort()); | |||
httpServerOptions.setHost("localhost"); | |||
|
|||
runner = new Runner(transactionSigner, httpClientOptions, httpServerOptions); | |||
runner = new Runner(transactionSigner, httpClientOptions, httpServerOptions, 5000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: use the more descriptive TimeUnit
JDK class i.e. TimeUnit.SECONDS.toMillis(5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -49,6 +49,12 @@ public void run() { | |||
return; | |||
} | |||
|
|||
if (config.getHttpListenHost().equals(config.getHttpListenHost()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using string comparison here for integers, whitespace risk i.e. "1" != "1 "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed config to now take InetAddress so that trailing spaces are no longer an issue. Also changed to use loopback as the default same what Pantheon is doing. Seems like a better default for security.
@Option( | ||
names = {"--downstream-http-request-timeout"}, | ||
description = | ||
"Timeout in ms to wait for downstream request to timeout (default: ${DEFAULT-VALUE})", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the unit? minutes, seconds, milliseconds, nanoseconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using milliseconds. Was using the ms abbreviation, but changed that to use milliseconds to make it clearer.
description = | ||
"Timeout in ms to wait for downstream request to timeout (default: ${DEFAULT-VALUE})", | ||
arity = "1") | ||
private Integer downstreamHttpRequestTimeout = 5_000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the bounding appropriate for the time unit i.e.should this type be a 'Long'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. should be a long as that is what vertx accepts as the type.
…llow more accurate comparison of host addresses
assertThat(config.getDownstreamHttpPort()).isEqualTo(5000); | ||
assertThat(config.getDownstreamHttpRequestTimeout()).isEqualTo(10000); | ||
assertThat(config.getHttpListenHost()).isEqualTo("localhost"); | ||
assertThat(config.getHttpListenHost()).isEqualTo(InetAddress.getLoopbackAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it worth having different values for listen-host and downstream to prove we haven't copied the same cmdline arg in to 2 different params?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. done.
@@ -34,12 +34,12 @@ | |||
|
|||
private final RequestMapper requestHandlerMapper; | |||
private final HttpServerOptions serverOptions; | |||
private final int httpRequestTimeout; | |||
private final Long httpRequestTimeout; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we use the unboxed versions of this when possible? (and others)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better. I was following what we were doing for the other types. Thought maybe pico had problem but it's fine. So now we are using long
@@ -41,6 +42,10 @@ public void setServerOptions(final HttpServerOptions serverOptions) { | |||
this.serverOptions = serverOptions; | |||
} | |||
|
|||
public void setHttpRequestTimeout(final Long requestTimeout) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wanted to leave that there, otherwise I can't tell if it has been set. Though 0 for a timeout value doesn't seem particularly useful anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to long. Validating that timeout > 0 as vertx doesn't allow 0 as a timeout value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of INetAddress
@@ -85,7 +85,7 @@ public static void setupEthFirewall() throws IOException, CipherException { | |||
httpServerOptions.setPort(serverSocket.getLocalPort()); | |||
httpServerOptions.setHost("localhost"); | |||
|
|||
runner = new Runner(transactionSigner, httpClientOptions, httpServerOptions); | |||
runner = new Runner(transactionSigner, httpClientOptions, httpServerOptions, 5000L); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5000L -> TimeUnit.SECONDS.toMills(5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done. using Duration version
|
||
Integer getDownstreamHttpPort(); | ||
|
||
String getHttpListenHost(); | ||
long getDownstreamHttpRequestTimeout(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
long
doesn't inform the reader of the units.
How about using Duration
instead?
https://docs.oracle.com/javase/8/docs/api/java/time/Duration.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
ASP-147: Sync with upstream
Improve some error handling and logging in EthFirewall