diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsFake.java b/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsFake.java index 191216a040..64d3c53094 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsFake.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsFake.java @@ -95,7 +95,7 @@ static Dependency randDep(final String scope) { return DcsFake.dep( UUID.randomUUID().toString(), UUID.randomUUID().toString(), - String.valueOf(Math.abs(rand.nextInt())), + String.valueOf(rand.nextInt(Integer.MAX_VALUE)), scope ); } @@ -125,7 +125,7 @@ private static Dependency randDep() { return DcsFake.dep( UUID.randomUUID().toString(), UUID.randomUUID().toString(), - String.valueOf(Math.abs(rand.nextInt())), + String.valueOf(rand.nextInt(Integer.MAX_VALUE)), scope ); } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/name/OnDefault.java b/eo-maven-plugin/src/main/java/org/eolang/maven/name/OnDefault.java index 6a636b1d16..53661cbf80 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/name/OnDefault.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/name/OnDefault.java @@ -60,7 +60,7 @@ public String value() { @Override public CommitHash hash() { - return new CommitHash.ChConstant(this.name.label().get()); + return new CommitHash.ChConstant(this.name.label().orElse("")); } @Override diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java index 9c8d1da6fc..4a02fb4b16 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/PullMojoTest.java @@ -295,27 +295,26 @@ void doesNotPullInOfflineMode(@TempDir final Path tmp) throws IOException { @Test @CaptureLogs - void showsWhereNotFoundWasDiscoveredAt(@TempDir final Path tmp, final Logs out) { + void showsWhereNotFoundWasDiscoveredAt(@TempDir final Path tmp, final Logs out) + throws IOException { + final FakeMaven mvn = new FakeMaven(tmp) + .withProgram( + "+package com.example\n", + "# This is the default 64+ symbols comment in front of named abstract object.", + "[] > main", + " org.eolang.org > @" + ) + .with( + "objectionaries", + new Objectionaries.Fake( + new OyRemote( + new ChRemote("master") + ) + ) + ); Assertions.assertThrows( Exception.class, - () -> { - new FakeMaven(tmp) - .withProgram( - "+package com.example\n", - "# This is the default 64+ symbols comment in front of named abstract object.", - "[] > main", - " org.eolang.org > @" - ) - .with( - "objectionaries", - new Objectionaries.Fake( - new OyRemote( - new ChRemote("master") - ) - ) - ) - .execute(new FakeMaven.Pull()); - }, + () -> mvn.execute(new FakeMaven.Pull()), "Pull mojo should fail, but it does not" ); Assertions.assertTrue( diff --git a/eo-runtime/src/main/java/org/eolang/Dataized.java b/eo-runtime/src/main/java/org/eolang/Dataized.java index 83cd8843bf..c75999b6f0 100644 --- a/eo-runtime/src/main/java/org/eolang/Dataized.java +++ b/eo-runtime/src/main/java/org/eolang/Dataized.java @@ -50,11 +50,21 @@ public final class Dataized { /** * Dataization level. + * + * @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on + * {@link Dataized#LEVEL} variables to prevent memory leaks. We should either find a place + * where this variable can be removed, or, if this is not possible + * (see https://github.com/objectionary/eo/pull/1930), come up with another solution. */ private static final ThreadLocal LEVEL = ThreadLocal.withInitial(() -> 0); /** * Max dataization level. + * + * @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on + * {@link Dataized#MAX_LEVEL} variables to prevent memory leaks. We should either find a place + * where this variable can be removed, or, if this is not possible + * (see https://github.com/objectionary/eo/pull/1930), come up with another solution. */ private static final ThreadLocal MAX_LEVEL = ThreadLocal.withInitial(() -> Integer.getInteger("max.dataization.log", 3)); diff --git a/eo-runtime/src/main/java/org/eolang/PhDefault.java b/eo-runtime/src/main/java/org/eolang/PhDefault.java index 3c1ed00624..3a12802956 100644 --- a/eo-runtime/src/main/java/org/eolang/PhDefault.java +++ b/eo-runtime/src/main/java/org/eolang/PhDefault.java @@ -61,6 +61,11 @@ public class PhDefault implements Phi, Cloneable { /** * Attributes nesting level. + * + * @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on + * {@link PhDefault#NESTING} to prevent memory leaks. We should either find a place where this + * variable can be removed, or, if this is not possible + * (see https://github.com/objectionary/eo/pull/1930), come up with another solution. */ private static final ThreadLocal NESTING = ThreadLocal.withInitial(() -> 0); diff --git a/eo-runtime/src/main/java/org/eolang/PhPackage.java b/eo-runtime/src/main/java/org/eolang/PhPackage.java index 7badbf4942..9e3d106349 100644 --- a/eo-runtime/src/main/java/org/eolang/PhPackage.java +++ b/eo-runtime/src/main/java/org/eolang/PhPackage.java @@ -102,6 +102,7 @@ public Phi take(final String name) { } else { res = new AtSetRho(this.objects.get().get(key), this, key).get(); } + this.objects.remove(); return res; } diff --git a/eo-runtime/src/main/java/org/eolang/PhTraced.java b/eo-runtime/src/main/java/org/eolang/PhTraced.java index 5f906510d3..2504a470e5 100644 --- a/eo-runtime/src/main/java/org/eolang/PhTraced.java +++ b/eo-runtime/src/main/java/org/eolang/PhTraced.java @@ -46,6 +46,11 @@ public final class PhTraced implements Phi { /** * Cages that are currently being dataized. If one cage is being datazed, and * it needs to be dataized inside current dataization, the locator of current object be here. + * + * @todo #2251:90min It is necessary to call {@link ThreadLocal#remove()} on + * {@link PhTraced#DATAIZING_CAGES} to prevent memory leaks. We should either find a + * place where this variable can be removed, or, if this is not possible + * (see https://github.com/objectionary/eo/pull/1930), come up with another solution. */ private static final ThreadLocal> DATAIZING_CAGES = ThreadLocal .withInitial(HashMap::new);