Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/github-build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: '11'
distribution: 'temurin'
- name: Build
run: mvn package
- name: Create Release
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/java-pr-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ jobs:
name: Build and Test

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: 1.8
java-version: '11'
distribution: 'temurin'
- name: Build and test
run: mvn verify
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<version>1.1.4</version>

<properties>
<vertx.version>4.5.15</vertx.version>
<vertx.version>5.0.4</vertx.version>
<logback.version>1.5.11</logback.version>
<jackson-databind.version>2.16.1</jackson-databind.version>
<junit.version>5.9.2</junit.version>
<jackson-databind.version>2.17.0</jackson-databind.version>
<junit.version>5.10.2</junit.version>
<hamcrest.version>2.2</hamcrest.version>
<maven.surefire.version>3.0.0-M5</maven.surefire.version>
<maven.surefire.version>3.2.5</maven.surefire.version>
</properties>

<dependencyManagement>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/kafka/vertx/demo/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import io.vertx.core.*;
import io.vertx.core.file.FileSystem;
import io.vertx.core.json.JsonObject;
import io.vertx.core.spi.resolver.ResolverProvider;
import org.apache.kafka.common.config.SslConfigs;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -40,7 +39,7 @@ public static void main(String[] args) {
long startTime = currentTimeMillis();

// Set vertx timeout to deal with slow DNS connections
System.setProperty(ResolverProvider.DISABLE_DNS_RESOLVER_PROP_NAME, "true");
System.setProperty("vertx.disableDnsResolver", "true");
Vertx vertx = Vertx.vertx(
new VertxOptions()
.setWarningExceptionTime(10).setWarningExceptionTimeUnit(TimeUnit.SECONDS)
Expand All @@ -58,7 +57,7 @@ public static void main(String[] args) {
Future<String> periodicProducerDeployment = vertx.deployVerticle(new PeriodicProducer());
Future<String> webSocketServerDeployment = vertx.deployVerticle(new WebSocketServer());

CompositeFuture.join(periodicProducerDeployment, webSocketServerDeployment)
Future.all(periodicProducerDeployment, webSocketServerDeployment)
.onSuccess(ok -> logger.info("✅ Application started in {}ms", currentTimeMillis() - startTime))
.onFailure(err -> logger.error("❌ Application failed to start", err));
}
Expand Down
16 changes: 7 additions & 9 deletions src/main/java/kafka/vertx/demo/WebSocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,12 @@ private Future<HttpServer> createRouterAndStartServer(JsonObject config) {

data.put("config", props);

engine.render(data, "webroot/index.html", res -> {
if (res.succeeded()) {
ctx.response().end(res.result());
} else {
logger.error(res.cause().getMessage());
ctx.fail(res.cause());
}
});
engine.render(data, "webroot/index.html")
.onSuccess(buffer -> ctx.response().end(buffer))
.onFailure(err -> {
logger.error(err.getMessage());
ctx.fail(err);
});
});

return startWebSocket(router);
Expand All @@ -106,7 +104,7 @@ private void handleWebSocket(ServerWebSocket webSocket) {
handleConsumeSocket(webSocket);
break;
default:
webSocket.reject();
webSocket.close();
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/test/java/kafka/vertx/demo/WebSocketServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ public class WebSocketServerTest {

@BeforeEach
void setup(Vertx vertx, VertxTestContext testContext) {
vertx.deployVerticle(new WebSocketServer(), res -> {
testContext.completeNow();
});
vertx.deployVerticle(new WebSocketServer())
.onComplete(testContext.succeeding(id -> testContext.completeNow()));
}

@Test
Expand All @@ -44,7 +43,8 @@ void getTemplateResponse(Vertx vertx, VertxTestContext testContext) {

client.get(8080, "localhost", "/")
.as(BodyCodec.string())
.send(testContext.succeeding(response -> testContext.verify(() -> {
.send()
.onComplete(testContext.succeeding(response -> testContext.verify(() -> {
assertThat(response.body(), CoreMatchers.containsString(EXPECTED));
testContext.completeNow();
})));
Expand Down