JaCoCo doesn't seem to work with org.springframework.data.cassandra.mapping.Table

330 views
Skip to first unread message

pavlina....@gmail.com

unread,
Feb 24, 2017, 7:25:17 AM2/24/17
to JaCoCo and EclEmma Users
Hi everyone,

our project is using org.springframework.data.cassandra.mapping.Table annotations to create tables in Cassandra automatically when the Java process starts. Unfortunately, when we enable JaCoCo to measure code coverage this table creation mechanism is omitted somehow and the tables are not created in Cassandra DB. We end-up with exception like this while making insert statements:


java.lang.IllegalArgumentException: Invalid value [Z@7e4afb38 of type unknown to the query builder
at com.datastax.driver.core.querybuilder.Utils.appendStringIfValid(Utils.java:133) ~[cassandra-driver-core-2.1.4.jar:na]
at com.datastax.driver.core.querybuilder.Utils.appendValue(Utils.java:113) ~[cassandra-driver-core-2.1.4.jar:na]
at com.datastax.driver.core.querybuilder.Utils.appendValue(Utils.java:92) ~[cassandra-driver-core-2.1.4.jar:na]
at com.datastax.driver.core.querybuilder.Utils.joinAndAppendValues(Utils.java:58) ~[cassandra-driver-core-2.1.4.jar:na]
at com.datastax.driver.core.querybuilder.Insert.buildQueryString(Insert.java:59) ~[cassandra-driver-core-2.1.4.jar:na]
at com.datastax.driver.core.querybuilder.Batch.buildQueryString(Batch.java:69) ~[cassandra-driver-core-2.1.4.jar:na]
at com.datastax.driver.core.querybuilder.BuiltStatement.toString(BuiltStatement.java:186) ~[cassandra-driver-core-2.1.4.jar:na]
at org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:500) ~[spring-cql-1.4.1.RELEASE.jar:na]
at org.springframework.cassandra.core.CqlTemplate$12.doInSession(CqlTemplate.java:494) ~[spring-cql-1.4.1.RELEASE.jar:na]
at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:471) ~[spring-cql-1.4.1.RELEASE.jar:na]
at org.springframework.cassandra.core.CqlTemplate.doExecute(CqlTemplate.java:494) ~[spring-cql-1.4.1.RELEASE.jar:na]
at org.springframework.cassandra.core.CqlTemplate.execute(CqlTemplate.java:1219) ~[spring-cql-1.4.1.RELEASE.jar:na]

Since this exception doesn't give much info we executed the CQL statement causing it from command line

When executing the same statement from cqlsh in Cassandra:

cqlsh> BEGIN BATCH INSERT INTO keyspace.dbschemaversion(updatedTime,schemaVersion,vrmVersion) VALUES (1487936595530,2,'');INSERT INTO keyspace.dbschemalatestversion(latestVersion) VALUES (2);APPLY BATCH;

We get error:

InvalidRequest: code=2200 [Invalid query] message="unconfigured table dbschemaversion"

Obviously the table is not created. But if we disable JaCoCo agent, the tables are created. Here is how a table looks using this annotation:


@Table(value = DbSchemaVersion.tableName)
public class DbSchemaVersion {

@org.springframework.data.annotation.Transient
public static final String tableName = "dbschemaversion";

@PrimaryKey
private Integer schemaVersion;

private String vrmVersion;

private Date updatedTime;

.... getters/setters
}


Any ideas anyone?

Evgeny Mandrikov

unread,
Feb 24, 2017, 7:52:18 AM2/24/17
to JaCoCo and EclEmma Users, pavlina....@gmail.com
Hi,

To investigate this deeper, would be better to provide complete example that demonstrates problem.

However here is blind guess based on FAQ (http://www.jacoco.org/jacoco/trunk/doc/faq.html, entry "My code uses reflection. Why does it fail when I execute it with JaCoCo?"):
To collect execution data JaCoCo instruments the classes under test which adds two members to the classes: A private static field $jacocoData and a private static method $jacocoInit(). Both members are marked as synthetic.
Please change your code to ignore synthetic members. This is a good practice anyways as also the Java compiler creates synthetic members in certain situation.

If this filtering is not presented in third-party library that you use, then probably better to report this to the vendor of library.

As a workaround maybe you can exclude classes that cause problem from instrumentation - see "excludes" property of an agent ( http://www.jacoco.org/jacoco/trunk/doc/agent.html )

Hope this helps.

pavlina....@gmail.com

unread,
Feb 24, 2017, 8:30:16 AM2/24/17
to JaCoCo and EclEmma Users, pavlina....@gmail.com
Thanks for your answer! I didn't know about those synthetic fields/methods. I will check with Spring data if they filter synthetic fields.

This makes even more sense, because Cassandra has naming restrictions for keyspace/table/column names. They must be alphanumeric underscores: https://docs.datastax.com/en/cql/3.1/cql/cql_reference/ref-lexical-valid-chars.html So it will definitely fail to create table with column $jacocoData

Evgeny Mandrikov

unread,
Feb 24, 2017, 7:31:36 PM2/24/17
to JaCoCo and EclEmma Users, pavlina....@gmail.com
Glad that this information was helpful.
Don't hesitate to post your findings here afterwards.
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages