Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Apr 27, 2024
2 parents 58135f6 + c0a5dca commit 0c3f311
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import com.jcabi.log.Logger;
import org.cactoos.Text;
import org.cactoos.text.Sticky;

/**
* Hash of tag from objectionary.
Expand All @@ -37,7 +36,7 @@ public final class ChRemote implements CommitHash {
/**
* Cached text of hashes.
*/
private static final Text CACHE = new Sticky(new CommitHashesText());
private static final Text CACHE = new CommitHashesText();

/**
* Tag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
*/
package org.eolang.maven.hash;

import org.cactoos.Scalar;

/**
* Hash of tag.
*
* @since 0.28.11
*/
public interface CommitHash {
@FunctionalInterface
public interface CommitHash extends Scalar<String> {

/**
* SHA Hash.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
package org.eolang.maven.hash;

import com.yegor256.WeAreOnline;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import org.cactoos.experimental.Threads;
import org.eolang.maven.BinarizeParseTest;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
Expand Down Expand Up @@ -67,4 +71,22 @@ void throwsCommitHashException() {
BinarizeParseTest.TO_ADD_MESSAGE
);
}

@Test
void isThreadSafe() {
final int threads = 200;
final String sample = new ChRemote("0.23.19").value();
MatcherAssert.assertThat(
"You can use this class concurrently",
StreamSupport.stream(
new Threads<>(
threads,
Stream.generate(
() -> new ChRemote("0.23.19")
).limit(threads).collect(Collectors.toList())
).spliterator(), false
).filter(str -> !sample.equals(str)).collect(Collectors.toList()),
Matchers.empty()
);
}
}

0 comments on commit 0c3f311

Please sign in to comment.