Skip to content

Commit 99baaa7

Browse files
Merge branch 'master' into ci/update-gradle-dependencies-instrumentation-20260323
2 parents 7975505 + ef62d3a commit 99baaa7

4 files changed

Lines changed: 30 additions & 17 deletions

File tree

.gitlab-ci.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,18 +222,24 @@ maven-central-pre-release-check:
222222
image: ${BUILDER_IMAGE_REPO}:${BUILDER_IMAGE_VERSION_PREFIX}base
223223
stage: .pre
224224
rules:
225+
- if: '$CI_COMMIT_BRANCH == "master"'
226+
when: on_success
227+
allow_failure: false
225228
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
226229
when: on_success
227230
allow_failure: false
228231
script:
229232
- |
230233
MAVEN_CENTRAL_USERNAME=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_username --with-decryption --query "Parameter.Value" --out text)
231234
MAVEN_CENTRAL_PASSWORD=$(aws ssm get-parameter --region us-east-1 --name ci.dd-trace-java.central_password --with-decryption --query "Parameter.Value" --out text)
232-
# See https://central.sonatype.org/publish/publish-portal-api/
233-
# 15e0cbbb-deff-421e-9e02-296a24d0cada is deployment, any deployment id listed in central work, the idea is to check whether the token can authenticate
234-
curl --request POST --include --fail https://central.sonatype.com/api/v1/publisher/status?id=15e0cbbb-deff-421e-9e02-296a24d0cada --header "Authorization: Bearer $(printf "$MAVEN_CENTRAL_USERNAME:$MAVEN_CENTRAL_PASSWORD" | base64)"
235-
if [ $? -ne 0 ]; then
236-
echo "Failed to authenticate against central. Check credentials, see https://datadoghq.atlassian.net/wiki/x/Oog5OgE"
235+
# See https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/
236+
# Use the staging API search endpoint to validate the tokens without relying on a specific deployment
237+
AUTHORIZATION_HEADER="Authorization: Bearer $(printf '%s:%s' "$MAVEN_CENTRAL_USERNAME" "$MAVEN_CENTRAL_PASSWORD" | base64)"
238+
if ! curl --silent --show-error --fail \
239+
"https://ossrh-staging-api.central.sonatype.com/manual/search/repositories?ip=any" \
240+
--header "$AUTHORIZATION_HEADER" \
241+
> /dev/null; then
242+
echo "Failed to authenticate tokens against maven central staging API. Check credentials and see https://datadoghq.atlassian.net/wiki/x/Oog5OgE"
237243
exit 1
238244
fi
239245

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ContextPayload.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
public class ContextPayload {
1818

1919
private static final Logger log = LoggerFactory.getLogger(ContextPayload.class);
20+
private static final int MAX_CONTEXT_SIZE = 1000;
2021
private final Map<String, String> context;
2122
public static final InjectAdapter SETTER = new InjectAdapter();
2223

@@ -39,20 +40,26 @@ public static ContextPayload from(final AgentSpan span) {
3940
}
4041

4142
public static ContextPayload read(final ObjectInput oi) throws IOException {
42-
try {
43-
final Object object = oi.readObject();
44-
if (object instanceof Map) {
45-
return new ContextPayload((Map<String, String>) object);
46-
}
47-
} catch (final ClassCastException | ClassNotFoundException ex) {
48-
log.debug("Error reading object", ex);
43+
final int size = oi.readInt();
44+
if (size < 0 || size > MAX_CONTEXT_SIZE) {
45+
log.debug("Dropping RMI context payload: size {} exceeds maximum {}", size, MAX_CONTEXT_SIZE);
46+
return null;
4947
}
50-
51-
return null;
48+
final Map<String, String> context = new HashMap<>(size * 2);
49+
for (int i = 0; i < size; i++) {
50+
final String key = oi.readUTF();
51+
final String value = oi.readUTF();
52+
context.put(key, value);
53+
}
54+
return new ContextPayload(context);
5255
}
5356

5457
public void write(final ObjectOutput out) throws IOException {
55-
out.writeObject(context);
58+
out.writeInt(context.size());
59+
for (final Map.Entry<String, String> entry : context.entrySet()) {
60+
out.writeUTF(entry.getKey());
61+
out.writeUTF(entry.getValue());
62+
}
5663
}
5764

5865
@ParametersAreNonnullByDefault

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/instrumentation/rmi/ContextPropagator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class ContextPropagator {
2020
private static final ObjID REGISTRY_ID = new ObjID(ObjID.REGISTRY_ID);
2121

2222
// RMI object id used to identify DataDog instrumentation
23-
public static final ObjID DD_CONTEXT_CALL_ID = new ObjID("Datadog.v1.context_call".hashCode());
23+
public static final ObjID DD_CONTEXT_CALL_ID = new ObjID("Datadog.v2.context_call".hashCode());
2424

2525
// Operation id used for checking context propagation is possible
2626
// RMI expects these operations to have negative identifier, as positive ones mean legacy

dd-java-agent/ddprof-lib/gradle.lockfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ch.qos.logback:logback-classic:1.2.13=testCompileClasspath,testRuntimeClasspath
55
ch.qos.logback:logback-core:1.2.13=testCompileClasspath,testRuntimeClasspath
66
com.datadoghq:dd-javac-plugin-client:0.2.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
7-
com.datadoghq:ddprof:1.39.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
7+
com.datadoghq:ddprof:1.40.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath
88
com.github.javaparser:javaparser-core:3.25.6=codenarc
99
com.github.spotbugs:spotbugs-annotations:4.9.8=compileClasspath,spotbugs,testCompileClasspath,testRuntimeClasspath
1010
com.github.spotbugs:spotbugs:4.9.8=spotbugs

0 commit comments

Comments
 (0)