Skip to content

Commit

Permalink
Don't require clustered to be set when creating a clustered vert.x
Browse files Browse the repository at this point in the history
  • Loading branch information
purplefox committed Feb 26, 2015
1 parent 373b380 commit 32a2842
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/main/java/io/vertx/core/impl/VertxFactoryImpl.java
Expand Up @@ -37,13 +37,15 @@ public Vertx vertx() {
@Override
public Vertx vertx(VertxOptions options) {
if (options.isClustered()) {
throw new IllegalArgumentException("Please use the asynchronous method to create a clustered Vertx");
throw new IllegalArgumentException("Please use Vertx.clusteredVertx() to create a clustered Vert.x instance");
}
return new VertxImpl(options);
}

@Override
public void clusteredVertx(VertxOptions options, final Handler<AsyncResult<Vertx>> resultHandler) {
// We don't require the user to set clustered to true if they use this method
options.setClustered(true);
new VertxImpl(options, resultHandler);
}

Expand Down
7 changes: 6 additions & 1 deletion src/test/java/io/vertx/test/core/CreateVertxTest.java
Expand Up @@ -62,14 +62,19 @@ public void testCreateClusteredVertxAsync() {
await();
}

/*
If the user doesn't explicitly set clustered to true, it should still create a clustered Vert.x
*/
@Test
public void testCreateNonClusteredVertxAsync() {
public void testCreateClusteredVertxAsyncDontSetClustered() {
VertxOptions options = new VertxOptions();
Vertx.clusteredVertx(options, ar -> {
assertTrue(ar.succeeded());
assertNotNull(ar.result());
assertTrue(options.isClustered());
testComplete();
});
await();
}

}

0 comments on commit 32a2842

Please sign in to comment.