-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed memory leak: JUnit4Core keeps reference to all Failures, Failur…
…es keep reference to the respective AssertionError, ArchRule.AssertionError kept reference to EvaluationResult, thus making it impossible to GC big results over the whole JUnit run. Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
- Loading branch information
1 parent
c8085cb
commit 8b859a4
Showing
6 changed files
with
112 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...integration-test/src/test/java/com/tngtech/archunit/testutils/ResultStoringExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.tngtech.archunit.testutils; | ||
|
||
import java.util.Properties; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import com.tngtech.archunit.ArchConfiguration; | ||
import com.tngtech.archunit.lang.EvaluationResult; | ||
import com.tngtech.archunit.lang.extension.ArchUnitExtension; | ||
import com.tngtech.archunit.lang.extension.EvaluatedRule; | ||
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
public class ResultStoringExtension implements ArchUnitExtension { | ||
private static final String UNIQUE_IDENTIFIER = "archunit-result-storing-extension"; | ||
|
||
private static final ConcurrentHashMap<String, EvaluationResult> storedResults = new ConcurrentHashMap<>(); | ||
|
||
@Override | ||
public String getUniqueIdentifier() { | ||
return UNIQUE_IDENTIFIER; | ||
} | ||
|
||
@Override | ||
public void configure(Properties properties) { | ||
} | ||
|
||
@Override | ||
public void handle(EvaluatedRule evaluatedRule) { | ||
storedResults.put(evaluatedRule.getResult().getFailureReport().toString(), evaluatedRule.getResult()); | ||
} | ||
|
||
public static void reset() { | ||
storedResults.clear(); | ||
} | ||
|
||
static EvaluationResult getEvaluationResultFor(String errorMessage) { | ||
return checkNotNull(storedResults.get(errorMessage), "No result was recorded for error message: %s", errorMessage); | ||
} | ||
|
||
public static void enable() { | ||
ArchConfiguration.get().configureExtension(UNIQUE_IDENTIFIER).setProperty("enabled", true); | ||
} | ||
|
||
public static void disable() { | ||
ArchConfiguration.get().configureExtension(UNIQUE_IDENTIFIER).setProperty("enabled", false); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...rc/test/resources/META-INF/services/com.tngtech.archunit.lang.extension.ArchUnitExtension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.tngtech.archunit.testutils.ResultStoringExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters