Skip to content

Commit

Permalink
fix: Update exception handling and improve logging (#1399)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWitt authored Dec 24, 2023
1 parent 95a3820 commit aa6bd8e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 24 deletions.
1 change: 1 addition & 0 deletions github-bot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
}

dependencies {
implementation 'io.quarkus:quarkus-info'
implementation 'io.quarkiverse.jgit:quarkus-jgit:3.0.6'
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkiverse.githubapi:quarkus-github-api:1.318.0'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.martinwitt.laughing_train.mining;

import io.github.martinwitt.laughing_train.mining.requests.MineNextProject;
import io.quarkus.logging.Log;
import io.quarkus.runtime.StartupEvent;
import io.vertx.core.DeploymentOptions;
import io.vertx.core.Future;
Expand All @@ -13,12 +14,10 @@
@ApplicationScoped
public class MiningStartup {

public static final String SERVICE_NAME = "miningStartup";

final Vertx vertx;
final AnalyzerResultsPersistence persistence;
final ProjectSupplier projectSupplier;
final SpoonPeriodicMiner spoonPeriodicMiner;
private final Vertx vertx;
private final AnalyzerResultsPersistence persistence;
private final ProjectSupplier projectSupplier;
private final SpoonPeriodicMiner spoonPeriodicMiner;

@Inject
public MiningStartup(
Expand All @@ -40,20 +39,12 @@ void startup(@Observes StartupEvent event) {
vertx.deployVerticle(persistence, options),
vertx.deployVerticle(projectSupplier, options))
.onFailure(Throwable::printStackTrace)
.onComplete(v -> System.out.println("All verticles deployed"))
.onComplete(v -> Log.info("All verticles deployed"))
.onSuccess(v -> startMining());
vertx
.eventBus()
.addInboundInterceptor(
v -> {
System.out.println("Received message: " + v.toString());
v.next();
});
vertx.exceptionHandler(v -> Log.error("Exception in vertx", v));
}

private void startMining() {
// vertx.setTimer(TimeUnit.MINUTES.toMillis(3), v -> vertx.eventBus()
// .publish("miner", new MineNextProject(QodanaPeriodicMiner.ANALYZER_NAME)));
vertx.setTimer(
TimeUnit.MINUTES.toMillis(2),
v ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ private RemoteProject getRandomProject() throws IOException {

private RemoteProject getKnownProject() {
var list = projectRepository.getAll();
if (list.isEmpty()) {
throw new IllegalStateException("No known projects found");
}
return list.get(random.nextInt(list.size()));
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package io.github.martinwitt.laughing_train.persistence.impl;

import static org.assertj.core.api.Assertions.assertThat;

import io.github.martinwitt.laughing_train.domain.entity.GitHubCommit;
import io.github.martinwitt.laughing_train.domain.entity.RemoteProject;
import io.quarkus.test.junit.QuarkusTest;
import jakarta.inject.Inject;
import org.instancio.Instancio;
import org.junit.jupiter.api.Test;

import java.time.LocalDateTime;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import org.instancio.Instancio;
import org.junit.jupiter.api.Test;

@QuarkusTest
class SqlProjectRepositoryTest {
Expand All @@ -23,8 +22,8 @@ class SqlProjectRepositoryTest {
void insertProject() {
RemoteProject remoteProject = Instancio.create(RemoteProject.class);
remoteProject.getCommits().stream()
.flatMap(v -> v.getAnalyzerStatuses().stream())
.forEach(v -> v.setLocalDateTime(LocalDateTime.now()));
.flatMap(v -> v.getAnalyzerStatuses().stream())
.forEach(v -> v.setLocalDateTime(LocalDateTime.now()));
sqlProjectRepository.save(remoteProject);
assertThat(sqlProjectRepository.findByProjectName(remoteProject.getProjectName())).isNotEmpty();
List<RemoteProject> byProjectName =
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Gradle properties
#Sat Sep 23 17:47:13 CEST 2023
#Sun Dec 24 17:33:05 CET 2023
org.gradle.caching=true
org.gradle.jvmargs=--add-exports jdk.compiler/com.sun.tools.javac.api\=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file\=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser\=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree\=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util\=ALL-UNNAMED
org.gradle.parallel=true
Expand Down

0 comments on commit aa6bd8e

Please sign in to comment.