Fix NPE in hibernate instrumentation
Also add each hibernate instrumentation project as a test dependency to the others.  This demonstrates a problem with muzzle and instrumentation context which currently causes the tests to fail.
MODIFY
dd-java-agent/instrumentation/hibernate/core-3.3/core-3.3.gradle
dd-java-agent/instrumentation/hibernate/core-3.3/core-3.3.gradle
@@ -44,6 +44,8 @@ dependencies {
testCompile project(':dd-java-agent:testing')
testCompile project(':dd-java-agent:instrumentation:jdbc')
+ testCompile project(':dd-java-agent:instrumentation:hibernate:core-4.0')
+ testCompile project(':dd-java-agent:instrumentation:hibernate:core-4.3')
testCompile group: 'org.hibernate', name: 'hibernate-core', version: '3.3.0.GA'
testCompile group: 'org.hibernate', name: 'hibernate-annotations', version: '+'

MODIFY
dd-java-agent/instrumentation/hibernate/core-3.3/src/main/java/datadog/trace/instrumentation/hibernate/core/v3_3/QueryInstrumentation.java
dd-java-agent/instrumentation/hibernate/core-3.3/src/main/java/datadog/trace/instrumentation/hibernate/core/v3_3/QueryInstrumentation.java
@@ -61,7 +61,9 @@ public class QueryInstrumentation extends AbstractHibernateInstrumentation {
final SessionState state =
SessionMethodUtils.startScopeFrom(
contextStore, query, "hibernate.query." + name, null, true);
+ if (state != null) {
DECORATOR.onStatement(state.getMethodScope().span(), query.getQueryString());
+ }
return state;
}

MODIFY
dd-java-agent/instrumentation/hibernate/core-4.0/core-4.0.gradle
dd-java-agent/instrumentation/hibernate/core-4.0/core-4.0.gradle
@@ -37,7 +37,8 @@ dependencies {
testCompile project(':dd-java-agent:testing')
testCompile project(':dd-java-agent:instrumentation:jdbc')
-
+ testCompile project(':dd-java-agent:instrumentation:hibernate:core-3.3')
+ testCompile project(':dd-java-agent:instrumentation:hibernate:core-4.3')
testCompile group: 'org.hibernate', name: 'hibernate-core', version: '4.0.0.Final'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'

MODIFY
dd-java-agent/instrumentation/hibernate/core-4.0/src/main/java/datadog/trace/instrumentation/hibernate/core/v4_0/QueryInstrumentation.java
dd-java-agent/instrumentation/hibernate/core-4.0/src/main/java/datadog/trace/instrumentation/hibernate/core/v4_0/QueryInstrumentation.java
@@ -61,7 +61,9 @@ public class QueryInstrumentation extends AbstractHibernateInstrumentation {
final SessionState state =
SessionMethodUtils.startScopeFrom(
contextStore, query, "hibernate.query." + name, null, true);
+ if (state != null) {
DECORATOR.onStatement(state.getMethodScope().span(), query.getQueryString());
+ }
return state;
}

MODIFY
dd-java-agent/instrumentation/hibernate/core-4.3/core-4.3.gradle
dd-java-agent/instrumentation/hibernate/core-4.3/core-4.3.gradle
@@ -37,6 +37,7 @@ dependencies {
testCompile project(':dd-java-agent:testing')
testCompile project(':dd-java-agent:instrumentation:jdbc')
+ testCompile project(':dd-java-agent:instrumentation:hibernate:core-3.3')
testCompile project(':dd-java-agent:instrumentation:hibernate:core-4.0')
testCompile group: 'org.hibernate', name: 'hibernate-core', version: '4.3.0.Final'

Fix NPE in hibernate instrumentation

Also add each hibernate instrumentation project as a test dependency to the others.  This demonstrates a problem with muzzle and instrumentation context which currently causes the tests to fail.