jersey
  1. jersey
  2. JERSEY-2160

A resource method with (@Context HttpServletRequest request) or (@Context HttpServletResponse response) does not inject into the arguments

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.3.1
    • Fix Version/s: 2.4
    • Component/s: core
    • Labels:
      None

      Description

      having method x(@Context HttpServletResponse response) throws 500, there is issue with injecting using @Context, having the field in resource class

      {@Context HttpServletResponse response;}

      method x() works fine, response is injected.

        Activity

        Hide
        Jakub Podlesak added a comment -

        Here is what we found out off-line with Jan Supol:

        There are two things involved. The injection into resource method parameter happens just fine,
        but what gets injected is a dynamic proxy. The proxy then fails to lookup appropriate request/resource instance.

        To fix this, i have updated Jersey internals so that no proxy gets injected when dealing with method parameters
        and the type to be injected is a parameter-less interface type.

        I have also added a new integration test that simulates the original reproducer.

        Show
        Jakub Podlesak added a comment - Here is what we found out off-line with Jan Supol: There are two things involved. The injection into resource method parameter happens just fine, but what gets injected is a dynamic proxy. The proxy then fails to lookup appropriate request/resource instance. To fix this, i have updated Jersey internals so that no proxy gets injected when dealing with method parameters and the type to be injected is a parameter-less interface type. I have also added a new integration test that simulates the original reproducer.
        Hide
        Jakub Podlesak added a comment -

        Fixed in the master branch.

        Show
        Jakub Podlesak added a comment - Fixed in the master branch.

          People

          • Assignee:
            Jakub Podlesak
            Reporter:
            jan.supol
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 3 hours
              3h