Skip to content

Commit

Permalink
Set WindowCache to be initialized during runtime (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi authored Jun 8, 2024
1 parent 49c9763 commit 9d0e428
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ ReflectiveClassBuildItem reflection() {

@BuildStep
void runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> producer) {
producer.produce(new RuntimeInitializedClassBuildItem("org.eclipse.jgit.transport.HttpAuthMethod$Digest"));
producer.produce(new RuntimeInitializedClassBuildItem("org.eclipse.jgit.internal.storage.file.WindowCache"));
producer.produce(new RuntimeInitializedClassBuildItem("org.eclipse.jgit.lib.GpgSigner"));
producer.produce(new RuntimeInitializedClassBuildItem("org.eclipse.jgit.transport.HttpAuthMethod$Digest"));
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
Expand All @@ -15,6 +16,7 @@

import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.internal.storage.file.WindowCache;
import org.eclipse.jgit.lib.ObjectReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
Expand Down Expand Up @@ -43,6 +45,15 @@ public String cloneRepository() throws Exception {
}
}

@GET
@Path("/windowcache_random_initialized")
@Produces(MediaType.TEXT_PLAIN)
public boolean windowCacheRandomInitialized() throws Exception {
Field field = WindowCache.class.getDeclaredField("rng");
field.setAccessible(true);
return field.get(WindowCache.getInstance()) != null;
}

@GET
@Path("/config")
@Produces(MediaType.TEXT_PLAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ void shouldDiff() {
given().get("/jgit/diff").then().body(is("153"));
}

@Test
void shouldRandomBeInitialized() {
given().get("/jgit/windowcache_random_initialized").then()
.log().ifValidationFails()
.statusCode(200)
.body(is("true"));
}

}

This file was deleted.

0 comments on commit 9d0e428

Please sign in to comment.