Skip to content

Tolerate AbstractMethodError for servletRequest remote port#11403

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
andrea.marziali/servlet-port
May 18, 2026
Merged

Tolerate AbstractMethodError for servletRequest remote port#11403
gh-worker-dd-mergequeue-cf854d[bot] merged 1 commit into
masterfrom
andrea.marziali/servlet-port

Conversation

@amarziali
Copy link
Copy Markdown
Contributor

What Does This Do

We have telemetry signals like this:

java.lang.AbstractMethodError
    at (redacted)
    at datadog.trace.instrumentation.servlet3.Servlet3Decorator.peerPort(Servlet3Decorator.java:67)
    at datadog.trace.instrumentation.servlet3.Servlet3Decorator.peerPort(Servlet3Decorator.java:14)
    at datadog.trace.bootstrap.instrumentation.decorator.HttpServerDecorator.onRequest(HttpServerDecorator.java:331)
    at datadog.trace.instrumentation.servlet3.Servlet3Decorator.onRequest(Servlet3Decorator.java:105)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
    at (redacted: 9 frames)

While this decorator works with a servlet 3 that would have bundled this method (getRemotePort is available from servlet 2.4 onward) it looks like some underlying request objects have not implemented it.

Muzzle should prevent linkage issues with the loaded runtime because (references):

datadog.trace.instrumentation.servlet3.Servlet3Instrumentation
  public interface javax.servlet.http.HttpServletRequest
   .....
       Method: public_or_protected non_static getAttribute(Ljava/lang/String;)Ljava/lang/Object;
    Method: public_or_protected non_static setAttribute(Ljava/lang/String;Ljava/lang/Object;)V
    Method: public_or_protected non_static getUserPrincipal()Ljava/security/Principal;
    Method: public_or_protected non_static getServletContext()Ljavax/servlet/ServletContext;
    Method: public_or_protected non_static getMethod()Ljava/lang/String;
    Method: public_or_protected non_static getRemoteAddr()Ljava/lang/String;
    Method: public_or_protected non_static getRemotePort()I

Now what can happen (but we cannot prove it) is that the underlying application is wrapping the request with a ServletRequestWrapper that's been compiled against an older servlet version. In this case, when the JVM do the invokeInterface it may hits the AbstractMethodError because not present in the bytecode.

This PR ensure that the error is properly ignored and that the full advice is not interrupted because of this.

Hence we do not surface the error in the telemetry since now it's handled (but we log in debug in case)

Motivation

Additional Notes

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@amarziali amarziali requested a review from a team as a code owner May 18, 2026 15:09
@amarziali amarziali requested review from vandonr and removed request for a team May 18, 2026 15:09
@amarziali amarziali added type: bug Bug report and fix inst:servlet Servlet instrumentation tag: telemetry error reported Reported by error telemetry labels May 18, 2026
@amarziali amarziali requested a review from mcculls May 18, 2026 15:10
@amarziali amarziali changed the title Tolerate AbstractMethodError for servletRequest remote port and host Tolerate AbstractMethodError for servletRequest remote port May 18, 2026
Copy link
Copy Markdown
Contributor

@mcculls mcculls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving as speculative fix, which we'll check by seeing if telemetry changes

@amarziali amarziali added this pull request to the merge queue May 18, 2026
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts Bot commented May 18, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 18, 2026

View all feedbacks in Devflow UI.

2026-05-18 16:20:05 UTC ℹ️ Start processing command /merge


2026-05-18 16:20:10 UTC ℹ️ MergeQueue: pull request added to the queue

The expected merge time in master is approximately 1h (p90).


2026-05-18 17:35:35 UTC ℹ️ MergeQueue: This merge request was merged

@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 18, 2026
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot merged commit 198a35d into master May 18, 2026
574 of 577 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d Bot deleted the andrea.marziali/servlet-port branch May 18, 2026 17:35
@github-actions github-actions Bot added this to the 1.63.0 milestone May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

inst:servlet Servlet instrumentation tag: telemetry error reported Reported by error telemetry type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants