Skip to content

Commit b663616

Browse files
authored
[Entitlements] Fix AbstractDelegateHttpsURLConnection "this" parameter type (#124304)
Our check methods injected by the instrumenter receive "this" as the second parameter. For internal classes like AbstractDelegateHttpsURLConnection we generally use a base type; in this case we were using javax.net.ssl.HttpsURLConnection, which is incorrect as AbstractDelegateHttpsURLConnection derives from java.net.HttpURLConnection. This was not failing in our tests because we don't actually use that parameter in that check function. Also, it was not failing on transform, just on retransformClasses, and only in JDK 24. Apparently, JDK 24 introduced new validation there (to be confirmed). And it was failing just on cloud as the APM agent there (which is loaded before our agent) connects to a https endpoint - our IT tests, and ./gradlew run --with-apm-server, use a http endpoint. Using https makes the JVM load AbstractDelegateHttpsURLConnection, making it one of the classes we need to retransform, triggering the VerifyError.
1 parent d4b1dc0 commit b663616

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

libs/entitlement/bridge/src/main/java/org/elasticsearch/entitlement/bridge/EntitlementChecker.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,7 @@ public interface EntitlementChecker {
518518
Class<?>[] classes
519519
);
520520

521-
void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(
522-
Class<?> callerClass,
523-
javax.net.ssl.HttpsURLConnection that
524-
);
521+
void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(Class<?> callerClass, java.net.HttpURLConnection that);
525522

526523
void check$sun_net_www_protocol_mailto_MailToURLConnection$connect(Class<?> callerClass, java.net.URLConnection that);
527524

libs/entitlement/src/main/java/org/elasticsearch/entitlement/runtime/api/ElasticsearchEntitlementChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1180,7 +1180,7 @@ private static boolean isFileUrlConnection(java.net.URLConnection urlConnection)
11801180
@Override
11811181
public void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(
11821182
Class<?> callerClass,
1183-
javax.net.ssl.HttpsURLConnection that
1183+
java.net.HttpURLConnection that
11841184
) {
11851185
policyManager.checkOutboundNetworkAccess(callerClass);
11861186
}

0 commit comments

Comments
 (0)