File tree Expand file tree Collapse file tree
main/java/org/eolang/maven Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818import java .util .Map ;
1919import java .util .concurrent .ConcurrentHashMap ;
2020import org .cactoos .scalar .Sticky ;
21+ import org .cactoos .scalar .Synced ;
2122import org .cactoos .scalar .Unchecked ;
2223
2324/**
2425 * All catalogs in one place, to avoid making multiple objects.
2526 *
2627 * @since 0.29
27- * @todo #4884:30min Use ReentranLock instead of synchronized block in the code.
28- * It will be more efficient and will not cause deadlocks.
29- * Don't forget to remove the PMD suppression after that.
3028 */
31- @ SuppressWarnings ("PMD.AvoidSynchronizedStatement" )
3229final class Catalogs {
3330
3431 /**
@@ -40,9 +37,9 @@ final class Catalogs {
4037 * Singleton.
4138 */
4239 private static final Unchecked <Boolean > TESTING = new Unchecked <>(
43- new Sticky <>(
44- () -> {
45- synchronized ( Catalogs . class ) {
40+ new Synced <>(
41+ new Sticky <>(
42+ () -> {
4643 boolean tests ;
4744 try {
4845 Class .forName ("org.junit.jupiter.api.Test" );
@@ -52,7 +49,7 @@ final class Catalogs {
5249 }
5350 return tests ;
5451 }
55- }
52+ )
5653 )
5754 );
5855
Original file line number Diff line number Diff line change 1313import java .util .UUID ;
1414import org .hamcrest .MatcherAssert ;
1515import org .hamcrest .Matchers ;
16- import org .junit .jupiter .api .Test ;
16+ import org .junit .jupiter .api .RepeatedTest ;
1717import org .junit .jupiter .api .extension .ExtendWith ;
1818
1919/**
2525@ ExtendWith (MktmpResolver .class )
2626@ SuppressWarnings ("PMD.JUnit5TestShouldBePackagePrivate" )
2727public final class CatalogsTest {
28- @ Test
28+ @ RepeatedTest ( 10 )
2929 void readsFromTojosConcurrently (@ Mktmp final Path tmp ) {
3030 final Tojos tojos = Catalogs .INSTANCE .make (tmp .resolve ("foreign" ), "json" );
3131 MatcherAssert .assertThat (
Original file line number Diff line number Diff line change 22# SPDX-License-Identifier: MIT
33
44junit.jupiter.execution.timeout.test.method.default = 3m
5+ junit.jupiter.execution.parallel.enabled = true
6+ junit.jupiter.execution.parallel.mode.default = concurrent
You can’t perform that action at this time.
0 commit comments