Skip to content

Commit

Permalink
Correctly set up SO_LINGER for the HTTP connector (dropwizard#2176)
Browse files Browse the repository at this point in the history
Jetty's `ServerConnector` accepts `soLingerTime` in milliseconds, rather
than in seconds as `Socket.setSoLinger` does [1]. Dropwizard on the other
hand after parsing the YML configuration and extracting the `soLingerTime` parameter
passes it to Jetty in seconds. As a result, the configuration gets really
confusing for users, because the configuration value is more than the actual
SO_LINGER timeout by 1000 times.

The fix is to pass the configuration value to Jetty's `ServerConnector`
in milliseconds.

[1]: http://www.eclipse.org/jetty/documentation/9.4.x/configuring-connectors.html
  • Loading branch information
arteam authored and joschi committed Oct 17, 2017
1 parent 350ff22 commit 78afd66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -555,7 +555,7 @@ protected ServerConnector buildConnector(Server server,

connector.setReuseAddress(reuseAddress);
if (soLingerTime != null) {
connector.setSoLingerTime((int) soLingerTime.toSeconds());
connector.setSoLingerTime((int) soLingerTime.toMilliseconds());
}
connector.setIdleTimeout(idleTimeout.toMilliseconds());
connector.setName(name);
Expand Down
Expand Up @@ -130,7 +130,7 @@ public void testBuildConnector() throws Exception {
assertThat(connector.getHost()).isEqualTo("127.0.0.1");
assertThat(connector.getAcceptQueueSize()).isEqualTo(1024);
assertThat(connector.getReuseAddress()).isTrue();
assertThat(connector.getSoLingerTime()).isEqualTo(30);
assertThat(connector.getSoLingerTime()).isEqualTo(30000);
assertThat(connector.getIdleTimeout()).isEqualTo(30000);
assertThat(connector.getName()).isEqualTo("test-http-connector");

Expand Down

0 comments on commit 78afd66

Please sign in to comment.