Fray Detects Concurrency Issues in JVM Languages
These articles are AI-generated summaries. Please check the original sources for full details.
Fray Detects Concurrency Issues in JVM Languages
Carnegie Mellon University has introduced Fray, a concurrency testing tool for JVM programs designed to identify and replay concurrency bugs. Written in Kotlin, Fray leverages recent research in concurrency testing, specifically shadow locking, to maximize bug detection rates.
Why This Matters
Traditional unit tests often fail to expose subtle concurrency issues that only manifest under specific timing conditions. These issues can lead to unpredictable behavior, data corruption, and system failures, with potential costs reaching into the millions for critical systems. Fray aims to bridge this gap by proactively identifying these bugs during development, reducing the risk of runtime failures.
Key Insights
- Shadow Locking: Fray employs shadow locking, a technique adding extra locks to mediate access to shared resources in a defined order.
- JDK Bug Discovery: Fray successfully identified bugs directly within the Java Development Kit (JDK).
- Tool Adoption: Fray is used in projects like Lucene, Kafka, Flink, and Guava.
Working Example
<plugin>
<groupId>org.pastalab.fray.maven</groupId>
<artifactId>fray-plugins-maven</artifactId>
<version>0.6.9</version>
<executions>
<execution>
<id>prepare-fray</id>
<goals>
<goal>prepare-fray</goal>
</goals>
</execution>
</executions>
</plugin>
<dependency>
<groupId>org.pastalab.fray</groupId>
<artifactId>fray-junit</artifactId>
<version>0.6.9</version>
<scope>test</scope>
</dependency>
plugins {
id("org.pastalab.fray.gradle") version "0.6.9"
}
@ExtendWith(FrayTestExtension.class)
public class MyFirstTest {
@ConcurrencyTest
public void myTest() {
…
}
}
Practical Applications
- Financial Systems: Banks can use Fray to ensure the atomicity of transactions, preventing data inconsistencies during concurrent operations.
- Pitfall: Relying solely on optimistic locking without comprehensive concurrency testing can lead to lost updates and data corruption in multi-threaded environments.
References:
Continue reading
Next article
GigaTIME generates a virtual population for tumor microenvironment modeling
Related Content
JEP 525 Refines Structured Concurrency with Timeout Handling in Java 26
JEP 525, included in JDK 26, introduces a timeout callback for custom joiners in structured concurrency, improving error handling and flexibility.
Java Concurrency from the Trenches: Navigating IO-Bound Challenges at Scale
This article details a real-world Java concurrency optimization resulting in 12-minute job completion time for processing 270K requests per second.
Find Out What Keystore the JVM Is Using
Locate the JVM’s default keystore (cacerts) using JAVA_HOME, system properties, or user-specific paths.