Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ testing {
suites {
val test by getting(JvmTestSuite::class) {
dependencies {
implementation(libs.spock.core)
implementation(libs.groovy)
implementation(libs.spock.core)
}
targets.configureEach {
testTask.configure {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ dependencies {
implementation("com.github.javaparser", "javaparser-symbol-solver-core", "3.24.4")

testImplementation(libs.bytebuddy)
testImplementation(libs.spock.core)
testImplementation("org.objenesis", "objenesis", "3.0.1")
testImplementation(libs.groovy)
testImplementation(libs.bundles.spock)
testImplementation("javax.servlet", "javax.servlet-api", "3.0.1")
testImplementation("com.github.spotbugs", "spotbugs-annotations", "4.2.0")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package datadog.communication.http

import static org.junit.jupiter.api.Assertions.assertThrows

import org.junit.jupiter.api.Test

import java.util.concurrent.ExecutorService
import java.util.concurrent.RejectedExecutionException
import java.util.concurrent.TimeUnit

import static groovy.test.GroovyAssert.shouldFail

class RejectingExecutorServiceTest {
ExecutorService executorService = new RejectingExecutorService()

@Test
void 'execute throws exception'() {
shouldFail(RejectedExecutionException) {
assertThrows(RejectedExecutionException) {
executorService.execute({})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;

/** A store that keeps track of coverage probes allocated for multiple threads. */
public abstract class ConcurrentCoverageStore<T extends CoverageProbes> implements CoverageStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import javax.annotation.Nullable;
import org.jacoco.core.analysis.Analyzer;
import org.jacoco.core.data.ExecutionDataStore;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datadog.trace.api.civisibility.domain.BuildModuleLayout;
import datadog.trace.civisibility.config.ExecutionSettings;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;

public class NoOpCoverageProcessor implements CoverageProcessor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import datadog.trace.api.civisibility.execution.TestExecutionHistory;
import datadog.trace.api.civisibility.telemetry.tag.RetryReason;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;

class ExecutionOutcomeImpl implements TestExecutionHistory.ExecutionOutcome {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.agent.builder.AgentBuilder.InitializationStrategy;
import net.bytebuddy.agent.builder.AgentBuilder.RedefinitionStrategy;
import net.bytebuddy.agent.builder.AgentBuilder.TypeStrategy;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.matcher.ElementMatcher.Junction.Conjunction;
import org.jetbrains.annotations.NotNull;
import org.joor.Reflect;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -248,7 +248,7 @@ public void testDuplicateInstrumentations()
assertEquals(probe1, probe2);
}

@NotNull
@Nonnull
private static CodeOriginProbe[] codeOriginProbes(String type) {
CodeOriginProbe entry =
new CodeOriginProbe(CODE_ORIGIN_ID1, true, Where.of(type, "entry", "()", "53"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import datadog.trace.bootstrap.instrumentation.api.Tags;
import datadog.trace.core.CoreTracer;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nonnull;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -109,7 +109,7 @@ public void budgets() {
}
}

@NotNull
@Nonnull
private Result getResult(
TracerAPI tracer, String sessionId, boolean captureSnapshot, Integer line) {
BudgetSink sink = new BudgetSink(getConfig(), mock(ProbeStatusSink.class));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package com.datadog.iast.test
import com.datadog.iast.model.VulnerabilityType
import com.datadog.iast.overhead.Operation
import com.datadog.iast.overhead.OverheadController
import com.github.javaparser.quality.Nullable
import datadog.trace.bootstrap.instrumentation.api.AgentSpan
import groovy.transform.CompileStatic
import javax.annotation.Nullable

@CompileStatic
class NoopOverheadController implements OverheadController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
import java.io.IOException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;

public class IastOptOutContext implements IastContext {

@Nonnull
@SuppressWarnings("unchecked")
@NotNull
@Override
public TaintedObjects getTaintedObjects() {
return TaintedObjects.NoOp.INSTANCE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicIntegerArray;
import java.util.function.Function;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;

public class OverheadContext {

Expand All @@ -28,7 +28,7 @@ public class OverheadContext {
@Override
public AtomicIntegerArray computeIfAbsent(
String key,
@NotNull Function<? super String, ? extends AtomicIntegerArray> mappingFunction) {
@Nonnull Function<? super String, ? extends AtomicIntegerArray> mappingFunction) {
if (this.size() >= GLOBAL_MAP_MAX_SIZE) {
super.clear();
}
Expand Down
12 changes: 0 additions & 12 deletions dd-java-agent/agent-llmobs/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion

plugins {
id 'com.gradleup.shadow'
id 'org.jetbrains.kotlin.jvm'
}

apply from: "$rootDir/gradle/java.gradle"
apply from: "$rootDir/gradle/version.gradle"
apply from: "$rootDir/gradle/test-with-kotlin.gradle"

kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
apiVersion = KotlinVersion.KOTLIN_1_6
languageVersion = KotlinVersion.KOTLIN_1_6
}
}

minimumBranchCoverage = 0.0
minimumInstructionCoverage = 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nullable;

public abstract class LLMObsEval {
private static final String METRIC_TYPE_SCORE = "score";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ abstract class InstrumentationSpecification extends DDSpecification implements A
def sw = new StringWriter()
PrintWriter pw = new PrintWriter(sw)
entry.value.eachWithIndex { Exception e, int i ->
pw.write('\n' as char)
pw.write((char)'\n')
pw.write "Location $i:\n"
def st = e.stackTrace
int loc = st.findIndexOf {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class HttpServerTest extends InstrumentationSpecification {

then:
clientResponse.code() == 500
IOUtils.readFully (clientResponse.body().byteStream()).contains("assert body != null")
IOUtils.readFully(clientResponse.body().byteStream()).contains("assert body != null")

cleanup:
server.stop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class TimerTaskContinuationTest extends InstrumentationSpecification {
def "test continuation activated when TimerTask runs (date)"() {
when:
runUnderTrace("parent", {
timer.schedule(timerTask, Instant.now().plusMillis(100).toDate())
timer.schedule(timerTask, Date.from(Instant.now().plusMillis(100)))
})
runLatch.await()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
import static datadog.trace.agent.test.utils.TraceUtils.runnableUnderTrace
import static java.time.Instant.now
import static java.time.temporal.ChronoUnit.SECONDS

import datadog.trace.agent.test.InstrumentationSpecification
import datadog.trace.api.Trace

import java.util.concurrent.Callable
import java.util.concurrent.StructuredTaskScope

import static datadog.trace.agent.test.utils.TraceUtils.runUnderTrace
import static datadog.trace.agent.test.utils.TraceUtils.runnableUnderTrace
import static java.time.Instant.now

class StructuredConcurrencyTest extends InstrumentationSpecification {
/**
* Tests the structured task scope with a single task.
Expand All @@ -26,7 +26,7 @@ class StructuredConcurrencyTest extends InstrumentationSpecification {
return true
}
})
taskScope.joinUntil(now() + 10) // Wait for 10 seconds at maximum
taskScope.joinUntil(now().plus(10, SECONDS))
result = task.get()
}
taskScope.close()
Expand Down Expand Up @@ -73,7 +73,7 @@ class StructuredConcurrencyTest extends InstrumentationSpecification {
taskScope.fork {
runnableUnderTrace("child3") {}
}
taskScope.joinUntil(now() + 10) // Wait for 10 seconds at maximum
taskScope.joinUntil(now().plus(10, SECONDS))
}
taskScope.close()

Expand Down Expand Up @@ -132,7 +132,7 @@ class StructuredConcurrencyTest extends InstrumentationSpecification {
taskScope.fork {
runnableUnderTrace("child2") {}
}
taskScope.joinUntil(now() + 10) // Wait for 10 seconds at maximum
taskScope.joinUntil(now().plus(10, SECONDS))
}
taskScope.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ apply from: "$rootDir/gradle/java.gradle"
dependencies {
compileOnly group: 'javax.ws.rs', name: 'jsr311-api', version: '1.1.1'

testImplementation libs.spock.junit4 // This legacy module still needs JUnit4.
testImplementation libs.spock.junit4 // This module still needs Spock with JUnit4.
testImplementation group: 'io.dropwizard', name: 'dropwizard-testing', version: '0.7.1'
testImplementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.3'
}
2 changes: 2 additions & 0 deletions dd-java-agent/instrumentation/junit/junit-5.3/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies {

testImplementation project(':dd-java-agent:agent-ci-visibility:civisibility-instrumentation-test-fixtures')

testImplementation libs.junit4 // This module still needs JUnit4.

// versions used below are not the minimum ones that we support,
// but the tests need to use them in order to be compliant with Spock 2.x
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: libs.versions.junit.platform.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class TestAssumptionLegacy {

@Test
public void test_fail_assumption_legacy() {
// Throw exception from legacy JUnit4 library.
throw new AssumptionViolatedException("assumption is not fulfilled");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dependencies {
compileOnly group: 'org.apache.kafka', name: 'kafka-clients', version: '0.11.0.0'
implementation project(':dd-java-agent:instrumentation:kafka:kafka-common')

testImplementation libs.spock.junit4 // This legacy module still needs JUnit4.
testImplementation libs.spock.junit4 // This module still needs Spock with JUnit4.
testImplementation group: 'org.apache.kafka', name: 'kafka-clients', version: '0.11.0.0'
testImplementation group: 'org.springframework.kafka', name: 'spring-kafka', version: '1.3.3.RELEASE'
testImplementation group: 'org.springframework.kafka', name: 'spring-kafka-test', version: '1.3.3.RELEASE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {

// Include latest version of kafka itself along with latest version of client libs.
// This seems to help with jar compatibility hell.
latestDepTestImplementation libs.spock.junit4 // This module still needs Spock with JUnit4.
latestDepTestImplementation group: 'org.apache.kafka', name: 'kafka_2.13', version: '2.+'
latestDepTestImplementation group: 'org.apache.kafka', name: 'kafka-clients', version: '2.+'
latestDepTestImplementation group: 'org.apache.kafka', name: 'kafka-streams', version: '2.+'
Expand Down
Loading