Set context CL for reliable weblogic connection #3870
+223
−71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #2409
Weblogic overrides the default
HttpURLConnection
implementation of the JDK with its own, as a consequence the agent is sometimes unable to connect to the remote server due to classpath issues.After digging into the WL implementation details, the reason we get a
ClassNotFoundException
is because the thread context classloader is used to load parts of the SSL/TLS implementation.When this happens, for example when calling
getInputStream()
orgetStatusCode()
on the connection, then we have to make sure the current thread context CL is able to load such classes, which is not the case by default because it's theShadedClassLoader
of the agent which is not aware of the weblogic implementation details that are only visible to WL and not in the bootstrap CL of the JVM.Luckily, if the thread context CL is set to the same CL as the one that the Weblogic flavor of
HttpURLConnection
is loaded from, we are able to load the class that was previously not found.Checklist