Skip to content

Commit 4cc35a7

Browse files
committed
Merge branch 'master' into sarahchen6/use-octo-sts
2 parents 6d7cedd + e82c8b5 commit 4cc35a7

File tree

112 files changed

+2688
-2189
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2688
-2189
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
issuer: https://gitlab.ddbuild.io
2+
3+
subject_pattern: "project_path:DataDog/apm-reliability/dd-trace-java:ref_type:tag:ref:v.*"
4+
5+
claim_pattern:
6+
project_path: "DataDog/apm-reliability/dd-trace-java"
7+
ref_type: "tag"
8+
ref: "v.*"
9+
10+
permissions:
11+
contents: "write"

.github/workflows/analyze-changes.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747

4848
- name: Build dd-trace-java for creating the CodeQL database
4949
run: |
50-
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G'" \
50+
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx3G -Xms2G'" \
5151
JAVA_HOME=$JAVA_HOME_8_X64 \
5252
JAVA_8_HOME=$JAVA_HOME_8_X64 \
5353
JAVA_11_HOME=$JAVA_HOME_11_X64 \
@@ -93,7 +93,7 @@ jobs:
9393
9494
- name: Build and publish artifacts locally
9595
run: |
96-
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G'" \
96+
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx3G -Xms2G'" \
9797
JAVA_HOME=$JAVA_HOME_8_X64 \
9898
JAVA_8_HOME=$JAVA_HOME_8_X64 \
9999
JAVA_11_HOME=$JAVA_HOME_11_X64 \

.github/workflows/update-gradle-dependencies.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
git push -u origin $BRANCH_NAME --force
2929
- name: Update Gradle dependencies
3030
run: |
31-
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx2G -Xms2G'" \
31+
GRADLE_OPTS="-Dorg.gradle.jvmargs='-Xmx3G -Xms2G'" \
3232
JAVA_HOME=$JAVA_HOME_8_X64 \
3333
JAVA_8_HOME=$JAVA_HOME_8_X64 \
3434
JAVA_11_HOME=$JAVA_HOME_11_X64 \

.gitlab/one-pipeline.locked.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# DO NOT EDIT THIS FILE MANUALLY
22
# This file is auto-generated by automation.
33
include:
4-
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/d44e89797a5a47c43cf712193abefe2178a004176606f7e01b77d1ec49a3ef5e/one-pipeline.yml
4+
- remote: https://gitlab-templates.ddbuild.io/libdatadog/one-pipeline/ca/a0486057161f85a77e39ad2aa60ac66bb52414696d9b3dd87177df1057b11295/one-pipeline.yml

communication/build.gradle

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

communication/build.gradle.kts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
plugins {
2+
`java-library`
3+
}
4+
5+
description = "communication"
6+
7+
apply(from = rootDir.resolve("gradle/java.gradle"))
8+
9+
dependencies {
10+
implementation(libs.slf4j)
11+
12+
api(project(":remote-config:remote-config-api"))
13+
implementation(project(":remote-config:remote-config-core"))
14+
implementation(project(":internal-api"))
15+
implementation(project(":utils:container-utils"))
16+
implementation(project(":utils:socket-utils"))
17+
implementation(project(":utils:version-utils"))
18+
19+
api(libs.okio)
20+
api(libs.okhttp)
21+
api(libs.moshi)
22+
implementation(libs.dogstatsd)
23+
24+
testImplementation(project(":utils:test-utils"))
25+
testImplementation(libs.bundles.junit5)
26+
testImplementation(libs.truth)
27+
testImplementation(libs.bytebuddy)
28+
testImplementation("org.msgpack:msgpack-core:0.8.20")
29+
testImplementation("org.msgpack:jackson-dataformat-msgpack:0.8.20")
30+
testImplementation(
31+
group = "com.squareup.okhttp3",
32+
name = "mockwebserver",
33+
version = libs.versions.okhttp.legacy.get() // actually a version range
34+
)
35+
}
36+
37+
val minimumBranchCoverage by extra(0.5)
38+
val minimumInstructionCoverage by extra(0.8)
39+
val excludedClassesCoverage by extra(
40+
listOf(
41+
"datadog.communication.ddagent.ExternalAgentLauncher",
42+
"datadog.communication.ddagent.ExternalAgentLauncher.NamedPipeHealthCheck",
43+
"datadog.communication.ddagent.SharedCommunicationObjects.FixedConfigUrlSupplier",
44+
"datadog.communication.ddagent.SharedCommunicationObjects.RetryConfigUrlSupplier",
45+
"datadog.communication.http.OkHttpUtils",
46+
"datadog.communication.http.OkHttpUtils.1",
47+
"datadog.communication.http.OkHttpUtils.ByteBufferRequestBody",
48+
"datadog.communication.http.OkHttpUtils.CustomListener",
49+
"datadog.communication.http.OkHttpUtils.GZipByteBufferRequestBody",
50+
"datadog.communication.http.OkHttpUtils.GZipRequestBodyDecorator",
51+
"datadog.communication.http.OkHttpUtils.JsonRequestBody",
52+
"datadog.communication.monitor.DDAgentStatsDConnection",
53+
"datadog.communication.monitor.DDAgentStatsDConnection.*",
54+
"datadog.communication.monitor.LoggingStatsDClient",
55+
"datadog.communication.BackendApiFactory",
56+
"datadog.communication.BackendApiFactory.Intake",
57+
"datadog.communication.EvpProxyApi",
58+
"datadog.communication.IntakeApi",
59+
"datadog.communication.util.IOUtils",
60+
"datadog.communication.util.IOUtils.1",
61+
)
62+
)
63+
val excludedClassesBranchCoverage by extra(
64+
listOf(
65+
"datadog.communication.ddagent.TracerVersion",
66+
"datadog.communication.BackendApiFactory",
67+
"datadog.communication.EvpProxyApi",
68+
"datadog.communication.IntakeApi",
69+
)
70+
)
71+
val excludedClassesInstructionCoverage by extra(
72+
listOf(
73+
// can't reach the error condition now
74+
"datadog.communication.fleet.FleetServiceImpl",
75+
"datadog.communication.ddagent.SharedCommunicationObjects",
76+
"datadog.communication.ddagent.TracerVersion",
77+
"datadog.communication.BackendApiFactory",
78+
"datadog.communication.BackendApiFactory.Intake",
79+
"datadog.communication.EvpProxyApi",
80+
"datadog.communication.IntakeApi",
81+
"datadog.communication.util.IOUtils",
82+
"datadog.communication.util.IOUtils.1",
83+
)
84+
)

components/environment/src/main/java/datadog/environment/CommandLine.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
class CommandLine {
2626
private static final String SUN_JAVA_COMMAND_PROPERTY = "sun.java.command";
27-
final List<String> fullCommand = findFullCommand();
27+
private final List<String> fullCommand = findFullCommand();
2828
final String name = getCommandName();
2929
final List<String> arguments = getCommandArguments();
3030

@@ -35,14 +35,14 @@ private List<String> findFullCommand() {
3535
}
3636

3737
private String getCommandName() {
38-
return fullCommand.isEmpty() ? null : fullCommand.get(0);
38+
return this.fullCommand.isEmpty() ? null : this.fullCommand.get(0);
3939
}
4040

4141
private List<String> getCommandArguments() {
42-
if (fullCommand.isEmpty()) {
43-
return fullCommand;
42+
if (this.fullCommand.isEmpty()) {
43+
return this.fullCommand;
4444
} else {
45-
return fullCommand.subList(1, fullCommand.size());
45+
return this.fullCommand.subList(1, this.fullCommand.size());
4646
}
4747
}
4848
}

components/environment/src/main/java/datadog/environment/EnvironmentVariables.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ private EnvironmentVariables() {}
1616
* Gets an environment variable value.
1717
*
1818
* @param name The environment variable name.
19-
* @return The environment variable value, {@code null} if missing or can't be retrieved.
19+
* @return The environment variable value, {@code null} if missing, can't be retrieved, or the
20+
* environment variable name is {@code null}.
2021
*/
2122
public static @Nullable String get(String name) {
2223
return getOrDefault(name, null);
@@ -28,9 +29,13 @@ private EnvironmentVariables() {}
2829
* @param name The environment variable name.
2930
* @param defaultValue The default value to return if the environment variable is missing or can't
3031
* be retrieved.
31-
* @return The environment variable value, {@code defaultValue} if missing or can't be retrieved.
32+
* @return The environment variable value, {@code defaultValue} if missing, can't be retrieved or
33+
* the environment variable name is {@code null}.
3234
*/
3335
public static String getOrDefault(@Nonnull String name, String defaultValue) {
36+
if (name == null) {
37+
return defaultValue;
38+
}
3439
try {
3540
String value = System.getenv(name);
3641
return value == null ? defaultValue : value;

components/environment/src/main/java/datadog/environment/SystemProperties.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package datadog.environment;
22

3+
import javax.annotation.Nonnull;
4+
35
/**
46
* Safely queries system properties against security manager.
57
*
@@ -13,7 +15,8 @@ private SystemProperties() {}
1315
* Gets a system property value.
1416
*
1517
* @param property The system property name.
16-
* @return The system property value, {@code null} if missing or can't be retrieved.
18+
* @return The system property value, {@code null} if missing, can't be retrieved, or the system
19+
* property name is {@code null}.
1720
*/
1821
public static String get(String property) {
1922
return getOrDefault(property, null);
@@ -25,9 +28,13 @@ public static String get(String property) {
2528
* @param property The system property name.
2629
* @param defaultValue The default value to return if the system property is missing or can't be
2730
* retrieved.
28-
* @return The system property value, {@code defaultValue} if missing or can't be retrieved.
31+
* @return The system property value, {@code defaultValue} if missing, can't be retrieved, or the
32+
* system property name is {@code null}.
2933
*/
30-
public static String getOrDefault(String property, String defaultValue) {
34+
public static String getOrDefault(@Nonnull String property, String defaultValue) {
35+
if (property == null) {
36+
return defaultValue;
37+
}
3138
try {
3239
return System.getProperty(property, defaultValue);
3340
} catch (SecurityException ignored) {
Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
11
package datadog.environment;
22

3-
import static org.junit.jupiter.api.Assertions.*;
3+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertNotNull;
6+
import static org.junit.jupiter.api.Assertions.assertNull;
47

58
import org.junit.jupiter.api.Test;
69

710
class EnvironmentVariablesTest {
811
private static final String EXISTING_ENV_VAR = "JAVA_8_HOME";
912
private static final String MISSING_ENV_VAR = "UNDEFINED_ENV_VAR";
13+
private static final String DEFAULT_VALUE = "DEFAULT";
1014

1115
@Test
1216
void testGet() {
17+
// Existing environment variable
1318
assertNotNull(EnvironmentVariables.get(EXISTING_ENV_VAR));
19+
// Missing environment variable
1420
assertNull(EnvironmentVariables.get(MISSING_ENV_VAR));
15-
assertThrows(NullPointerException.class, () -> EnvironmentVariables.get(null));
21+
// Null values
22+
assertDoesNotThrow(() -> EnvironmentVariables.get(null));
23+
assertNull(EnvironmentVariables.get(null));
1624
}
1725

1826
@Test
1927
void testGetOrDefault() {
28+
// Existing environment variable
2029
assertNotNull(EnvironmentVariables.getOrDefault(EXISTING_ENV_VAR, null));
21-
22-
assertEquals("", EnvironmentVariables.getOrDefault(MISSING_ENV_VAR, ""));
30+
// Missing environment variable
31+
assertEquals(DEFAULT_VALUE, EnvironmentVariables.getOrDefault(MISSING_ENV_VAR, DEFAULT_VALUE));
32+
assertNull(EnvironmentVariables.getOrDefault(MISSING_ENV_VAR, null));
33+
// Null values
34+
assertDoesNotThrow(() -> EnvironmentVariables.getOrDefault(null, DEFAULT_VALUE));
35+
assertEquals(DEFAULT_VALUE, EnvironmentVariables.getOrDefault(null, DEFAULT_VALUE));
36+
assertDoesNotThrow(() -> EnvironmentVariables.getOrDefault(MISSING_ENV_VAR, null));
2337
assertNull(EnvironmentVariables.getOrDefault(MISSING_ENV_VAR, null));
24-
25-
assertThrows(NullPointerException.class, () -> EnvironmentVariables.getOrDefault(null, ""));
2638
}
2739
}

0 commit comments

Comments
 (0)