Check-then-Act Misuses of Java Concurrent Collection

Our empirical study analyzed misused as well as correctly used check-then-act idioms of Java concurrent collections. In this study, we quantitatively and qualitatively analyzed 28 widely-used open source Java projects that use Java concurrency collections. We reported the buggy instances of the idioms to developers. We also implemented a tool, CTADetector, to help us analyze the code.


Check-Then-Act Misuse of Java Concurrent Collections

By Yu Lin, Danny Dig.
6th IEEE International Conference on Software Testing, Verification and Validation
(ICST 2013), Luxembourg, Mar. 2013
This paper won the Best Paper Award of ICST 2013.

Evaluation Subjects and Bug Reports

The following table contains source downloads for the subjects that we used in the study, as well as the bug reports we sent to developers.

Subjects Version Source Description Bug Reports
Annsor 1.0.3 annsor-1.0.3.tar.gz Annotation runtime processor
Apache Cassandra 1.1.1 cassandra-1.1.1.tar.gz Distributed database CASSANDRA-4402
Apache CXF 2.6.1 cxf-2.6.1.tar.gz Open source services framework CXF-4404
Apache Lucene 4.0.0 lucene-4.0.0.tar.gz Text search engine library
Apache Mina 2.0.4 mina-2.0.4.tar.gz Network application framework MINA-897
Apache Struts 2.3.4 struts-2.3.4.tar.gz Web applications framework STRUTS-3845
Apache Tomcat 7.0.28 tomcat-7.0.28.tar.gz Servlet container Bug 53498
Apache Trinidad 2.0.1 trinidad-2.0.1.tar.gz JSF framework TRINIDAD-2287
Apache Wicket 1.5.7 wicket-1.5.7.tar.gz Java web framework WICKET-4646
BlazeDS 4.0.1 blazeds-4.0.1.tar.gz Web messaging technology BLZ-664
Carbonado 1.2.3 carbonado-1.2.3.tar.gz Persistence abstraction layer
CBB 1.0 cbb-1.0.tar.gz Concurrent Building Blocks
DWR 1.1 dwr-1.1.tar.gz Ajax for Java
Ektorp 1.1.1 ektorp-1.1.1.tar.gz Java API for CouchDB
Flexive 3.0.6 flexive-3.1.6.tar.gz Content management system FX-971
Glassfish 3.1.2 glassfish-3.1.2.tar.gz Application server GLASSFISH-18964
Granite 2.3.2 graniteds-2.3.2.tar.gz Data Service GDS-1028
Hazelcast 2.0.4 hazelcast-2.0.4.tar.gz Data distribution platform HAZELCAST-221
Ifw2 1.33 ifw2-1.33.tar.gz Web application framework
JBoss AOP 2.2.2 jboss-aop-2.2.2.tar.gz Aspected oriented framework JBAOP-813
JSefa 0.9.3 jsefa-0.9.3.tar.gz Object serialization library
Memcache memcache-client.tar.gz Memory object caching system
Open EJB 4.0.0 openejb-4.0.0.tar.gz EJB container OPENEJB-1880
Open JDK 8 openjdk8.tar.gz Java development kit 8 Bug 1280
RestEasy 2.3.4 resteasy-2.3.4.tar.gz JAX-RS client framework RESTEASY-744
Tersus tersus.tar.gz Visual programming platform
Vo Urp vo-urp.tar.gz Data models translator
Zimbra zimbra.tar.gz Collaboration server Bug 76594

Analysis Tool


Our analysis tool, CTADetector, is an Eclipse plugin. CTADetector uses pattern-based static analysis technique to detect check-then-act idioms for Java concurrent collections and semi-automatic code transformation to generate patches for misused idioms. The plugin is avaible for downlaod.

How to use

Tool Demo

The following are the snapshots of the tool:

Start Analysis
Analysis Result


The source code of CTADetector can be downloaded here. The source code of Eclipse headless plugin of CTADetector is here.

Integrate with Google ShipShape

We also integrated CTADetector with Google static analysis platform, ShipShape. ShipShape can run with docker images that are pulled from Docker Hub or local docker images.

Run with Docker Hub image

Build and run with local docker image

Notice that ShipShape runs CTADetector as an Eclipse plugin in Eclipse headless mode, so the input directory must be an Eclipse project (>=Eclipse 4.4.2, Luna), i.e., the dir must contain .project file.

Run examples and end to end test:

The source code dir contains an example in dir CTADetector_analyzer/testdata/apache-mina-2.0.4/src/mina-core. You can use this dir as input dir to try out the plugin.

To run end to end test: first move the source code into the ShipShape repo as described above, then run $ ./shipshape/CTADetector_analyzer/test/ --tag local. The output log is in CTADetector_end_to_end_test.log