Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE in instrumentation/apache-httpclient/apache-httpclient-2.0/javaagent #5944

Closed
dgradecak opened this issue Apr 27, 2022 · 5 comments
Closed
Labels
bug Something isn't working

Comments

@dgradecak
Copy link
Contributor

If the httpclient executeMethod is used with 3 parameters like getClient(uri).executeMethod(null, request, null) which is a valid call
the v2 extensions does not add any traces since a NPE pops up at the line

url.append(hostConfiguration.getProtocol().getScheme());

Since this issues shows up only if the execution is using a different httpclient (apache commons) method signature => getClient(uri).executeMethod(null, request, null) instead of the tested getClient(uri).executeMethod(request)

I will provide a PR for this

@dgradecak dgradecak added the bug Something isn't working label Apr 27, 2022
@dgradecak
Copy link
Contributor Author

after understanding how the build for different versions work, it seems I cannot make a logical test to make thinks work with http-client commons 2.0 and 3.1

This is an extract from buil.gradle.kts and it seems the extensions is meant to be used with those versions

dependencies {
  library("commons-httpclient:commons-httpclient:2.0")

  latestDepTestLibrary("commons-httpclient:commons-httpclient:3.+") // see apache-httpclient-4.0 module
}

since the signature(null, method, null) is not allowed in 2.0 but is in 3.1 and thus the test fails

furthermore when building with -PtestLatestDeps=true all tests are passing

could someone please point me to how this should be correctly tested so that the PR would be accepted?

should I rather create a supported extension for instrumentation/apache-httpclient/apache-httpclient-3.1?

@mateuszrzeszutek
Copy link
Member

I think you could try passing the testLatestDeps param to test via system property:

tasks {
  test {
    systemProperty("testLatestDeps", findProperty("testLatestDeps") as Boolean)
  }
}

And then, you could use assumptions to skip that one particular test when you're not running latest deps.

@dgradecak
Copy link
Contributor Author

thank you for the input @mateuszrzeszutek

I managed to do something, since I wanted the whole test class to be skipped

@IgnoreIf({ !Boolean.getBoolean("testLatestDeps") })
class CommonsHttpClientNPETest extends HttpClientTest<HttpMethod> implements AgentTestTrait {
 ...

is this something that is ok, since I could not see such a usage in the sources?

@mateuszrzeszutek
Copy link
Member

It should be okay, I think -- just leave a comment that very briefly explains why it's being ignored and it'll be fine.

dgradecak added a commit to dgradecak/opentelemetry-java-instrumentation that referenced this issue Apr 28, 2022
dgradecak added a commit to dgradecak/opentelemetry-java-instrumentation that referenced this issue Apr 28, 2022
dgradecak added a commit to dgradecak/opentelemetry-java-instrumentation that referenced this issue Apr 28, 2022
dgradecak added a commit to dgradecak/opentelemetry-java-instrumentation that referenced this issue Apr 28, 2022
trask pushed a commit that referenced this issue Apr 29, 2022
* fix NPE for commons-httpclient v3.1 (#5944)

* fix NPE for commons-httpclient v3.1 (#5944) - spotless fixes

* extracting abstract class with reused code (#5944)
@laurit
Copy link
Contributor

laurit commented Apr 29, 2022

Resolved with #5949

@laurit laurit closed this as completed Apr 29, 2022
RashmiRam pushed a commit to RashmiRam/opentelemetry-auto-instr-java that referenced this issue May 23, 2022
…etry#5949)

* fix NPE for commons-httpclient v3.1 (open-telemetry#5944)

* fix NPE for commons-httpclient v3.1 (open-telemetry#5944) - spotless fixes

* extracting abstract class with reused code (open-telemetry#5944)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants