Skip to content

Commit

Permalink
Clean up generics for the JettyServer
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Oct 15, 2019
1 parent 7678927 commit 963d4fb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

import static java.util.concurrent.TimeUnit.SECONDS;

public class JettyServer<T extends JettyServer> implements Server<T> {
public class JettyServer implements Server<JettyServer> {

private static final Logger LOG = Logger.getLogger(JettyServer.class.getName());
private static final int MAX_SHUTDOWN_RETRIES = 8;
Expand Down Expand Up @@ -155,12 +155,12 @@ public void addServlet(Servlet servlet, String pathSpec) {
}

@Override
public T setHandler(HttpHandler handler) {
public JettyServer setHandler(HttpHandler handler) {
if (server.isRunning()) {
throw new IllegalStateException("You may not add a handler to a running server");
}
this.handler = Objects.requireNonNull(handler, "Handler to use must be set.");
return (T) this;
return this;
}

@Override
Expand All @@ -169,7 +169,7 @@ public boolean isStarted() {
}

@Override
public T start() {
public JettyServer start() {
try {
// If there are no routes, we've done something terribly wrong.
if (handler == null) {
Expand All @@ -182,8 +182,7 @@ public T start() {

PortProber.waitForPortUp(getUrl().getPort(), 10, SECONDS);

//noinspection unchecked
return (T) this;
return this;
} catch (Exception e) {
try {
stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ private static Object[] createRemotes() throws URISyntaxException {
LocalNode localNode = LocalNode.builder(bus, clientFactory, nodeUri)
.add(CAPS, createFactory(nodeUri))
.build();
Server<?> nodeServer = new JettyServer<>(
Server<?> nodeServer = new JettyServer(
new BaseServerOptions(
new MapConfig(ImmutableMap.of("server", ImmutableMap.of("port", port)))));
nodeServer.setHandler(localNode);
Expand Down

0 comments on commit 963d4fb

Please sign in to comment.