Skip to content

Commit 1eb01c1

Browse files
Merge branch 'master' into bdu/spotbugs-bump-need-jdk11-min
2 parents 0e4993f + d8d09c6 commit 1eb01c1

File tree

33 files changed

+277
-149
lines changed

33 files changed

+277
-149
lines changed

buildSrc/src/main/kotlin/CIJobsExtensions.kt renamed to buildSrc/src/main/kotlin/datadog/gradle/plugin/ci/CIJobsExtensions.kt

File renamed without changes.

buildSrc/src/main/kotlin/datadog/gradle/plugin/config/SupportedConfigPlugin.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class SupportedConfigPlugin : Plugin<Project> {
1919
className.set(extension.className)
2020
}
2121

22-
val sourceset = targetProject.extensions.getByType(SourceSetContainer::class.java).named(SourceSet.MAIN_SOURCE_SET_NAME)
23-
sourceset.configure {
22+
val sourceSet = targetProject.extensions.getByType(SourceSetContainer::class.java).named(SourceSet.MAIN_SOURCE_SET_NAME)
23+
sourceSet.configure {
2424
java.srcDir(generateTask)
2525
}
2626

buildSrc/src/main/kotlin/datadog/gradle/plugin/muzzle/VersionSet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class VersionSet(versions: Collection<Version>) {
3030
return resultSet.map { it.version }
3131
}
3232

33-
private class ParsedVersion(val version: Version) : Comparable<ParsedVersion> {
33+
internal class ParsedVersion(val version: Version) : Comparable<ParsedVersion> {
3434
companion object {
3535
private val dotPattern = Regex("\\.")
3636
private const val VERSION_SHIFT = 12

buildSrc/src/test/groovy/datadog/gradle/plugin/muzzle/RangeQueryTest.groovy

Lines changed: 0 additions & 30 deletions
This file was deleted.

buildSrc/src/test/groovy/datadog/gradle/plugin/muzzle/VersionSetTest.groovy

Lines changed: 0 additions & 91 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package datadog.gradle.plugin.muzzle
2+
3+
import org.eclipse.aether.artifact.Artifact
4+
import org.eclipse.aether.artifact.DefaultArtifact
5+
import org.eclipse.aether.resolution.VersionRangeRequest
6+
import org.gradle.internal.impldep.org.junit.Assert.assertTrue
7+
import org.junit.jupiter.api.Test
8+
9+
class RangeQueryTest {
10+
private val system = MuzzleMavenRepoUtils.newRepositorySystem()
11+
private val session = MuzzleMavenRepoUtils.newRepositorySystemSession(system)
12+
13+
@Test
14+
fun `test range request`() {
15+
// compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.5.0', ext: 'pom'
16+
val directiveArtifact: Artifact = DefaultArtifact("org.codehaus.groovy", "groovy-all", "jar", "[2.5.0,2.5.8)")
17+
val rangeRequest = VersionRangeRequest().apply {
18+
repositories = MuzzleMavenRepoUtils.MUZZLE_REPOS
19+
artifact = directiveArtifact
20+
}
21+
22+
// This call makes an actual network request, which may fail if network access is limited.
23+
val rangeResult = system.resolveVersionRange(session, rangeRequest)
24+
25+
assertTrue(rangeResult.versions.size >= 8)
26+
}
27+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package datadog.gradle.plugin.muzzle
2+
3+
import org.eclipse.aether.version.Version
4+
import org.junit.jupiter.api.Assertions.assertEquals
5+
import org.junit.jupiter.api.Test
6+
7+
class VersionSetTest {
8+
9+
@Test
10+
fun `parse versions properly`() {
11+
data class Case(
12+
val version: Version,
13+
val versionNumber: Long,
14+
val ending: String
15+
)
16+
17+
val cases = listOf(
18+
Case(ver("1.2.3"), num(1, 2, 3), ""),
19+
Case(ver("4.5.6-foo"), num(4, 5, 6), "foo"),
20+
Case(ver("7.8.9.foo"), num(7, 8, 9), "foo"),
21+
Case(ver("10.11.12.foo-bar"), num(10, 11, 12), "foo-bar"),
22+
Case(ver("13.14.foo-bar"), num(13, 14, 0), "foo-bar"),
23+
Case(ver("15.foo"), num(15, 0, 0), "foo"),
24+
Case(ver("16-foo"), num(16, 0, 0), "foo")
25+
)
26+
27+
for (c in cases) {
28+
val parsed = VersionSet.ParsedVersion(c.version)
29+
assertEquals(c.versionNumber, parsed.versionNumber, "versionNumber for ${c.version}")
30+
assertEquals(c.ending, parsed.ending, "ending for ${c.version}")
31+
assertEquals(
32+
c.versionNumber shr 12,
33+
parsed.majorMinor.toLong(),
34+
"majorMinor for ${c.version}"
35+
)
36+
}
37+
}
38+
39+
@Test
40+
fun `select low and high from major minor`() {
41+
val versionsCases = listOf(
42+
listOf(
43+
ver("4.5.6"),
44+
ver("1.2.3")
45+
),
46+
listOf(
47+
ver("1.2.3"),
48+
ver("1.2.1"),
49+
ver("1.3.0"),
50+
ver("1.2.7"),
51+
ver("1.4.17"),
52+
ver("1.4.1"),
53+
ver("1.4.0"),
54+
ver("1.4.10")
55+
)
56+
)
57+
58+
val expectedCases = listOf(
59+
listOf(
60+
ver("1.2.3"),
61+
ver("4.5.6")
62+
),
63+
listOf(
64+
ver("1.2.1"),
65+
ver("1.2.7"),
66+
ver("1.3.0"),
67+
ver("1.4.0"),
68+
ver("1.4.17")
69+
)
70+
)
71+
72+
versionsCases.zip(expectedCases).forEach { (versions, expected) ->
73+
val versionSet = VersionSet(versions)
74+
assertEquals(expected, versionSet.lowAndHighForMajorMinor)
75+
}
76+
}
77+
78+
private fun ver(v: String): Version = TestVersion(v)
79+
80+
private fun num(major: Int, minor: Int, micro: Int): Long {
81+
var result = major.toLong()
82+
result = (((result shl 12) + minor) shl 12) + micro
83+
return result
84+
}
85+
86+
private class TestVersion(private val v: String) : Version {
87+
override fun compareTo(other: Version?): Int {
88+
if (other is TestVersion) {
89+
return v.compareTo(other.v)
90+
}
91+
92+
return 1
93+
}
94+
95+
override fun equals(other: Any?): Boolean =
96+
other is TestVersion && v == other.v
97+
98+
override fun hashCode(): Int = v.hashCode()
99+
100+
override fun toString(): String = v
101+
}
102+
}

communication/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies {
1313
implementation(project(":remote-config:remote-config-core"))
1414
implementation(project(":internal-api"))
1515
implementation(project(":utils:container-utils"))
16+
implementation(project(":utils:filesystem-utils"))
1617
implementation(project(":utils:socket-utils"))
1718
implementation(project(":utils:version-utils"))
1819

communication/src/main/java/datadog/communication/monitor/DDAgentStatsDConnection.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.timgroup.statsd.NoOpDirectStatsDClient;
99
import com.timgroup.statsd.NonBlockingStatsDClientBuilder;
1010
import com.timgroup.statsd.StatsDClientErrorHandler;
11+
import datadog.common.filesystem.Files;
1112
import datadog.environment.OperatingSystem;
1213
import datadog.trace.api.Config;
1314
import datadog.trace.relocate.api.IOLogger;
@@ -186,7 +187,7 @@ private void discoverConnectionSettings() {
186187
}
187188

188189
if (null == host) {
189-
if (!OperatingSystem.isWindows() && new File(DEFAULT_DOGSTATSD_SOCKET_PATH).exists()) {
190+
if (!OperatingSystem.isWindows() && Files.exists(new File(DEFAULT_DOGSTATSD_SOCKET_PATH))) {
190191
log.info("Detected {}. Using it to send StatsD data.", DEFAULT_DOGSTATSD_SOCKET_PATH);
191192
host = DEFAULT_DOGSTATSD_SOCKET_PATH;
192193
port = 0; // tells dogstatsd client to treat host as a socket path

components/json/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ plugins {
55
apply(from = "$rootDir/gradle/java.gradle")
66

77
jmh {
8-
version = "1.28"
8+
jmhVersion = libs.versions.jmh.get()
99
}

0 commit comments

Comments
 (0)