Skip to content

Commit 05a9ffe

Browse files
authored
[Entitlements] Fix AbstractDelegateHttpsURLConnection "this" parameter type (#124304) (#124325)
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 c41afd5 commit 05a9ffe

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,7 @@ public interface EntitlementChecker {
510510
Class<?>[] classes
511511
);
512512

513-
void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(
514-
Class<?> callerClass,
515-
javax.net.ssl.HttpsURLConnection that
516-
);
513+
void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(Class<?> callerClass, java.net.HttpURLConnection that);
517514

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

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ private static boolean isFileUrlConnection(java.net.URLConnection urlConnection)
11721172
@Override
11731173
public void check$sun_net_www_protocol_https_AbstractDelegateHttpsURLConnection$connect(
11741174
Class<?> callerClass,
1175-
javax.net.ssl.HttpsURLConnection that
1175+
java.net.HttpURLConnection that
11761176
) {
11771177
policyManager.checkOutboundNetworkAccess(callerClass);
11781178
}

0 commit comments

Comments
 (0)