Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8264270

NullPointerException when using matcher on ParameterizedTypeReference

XMLWordPrintable

    • x86_64
    • os_x

      A DESCRIPTION OF THE PROBLEM :
      The Java compiler fails with a Null Pointer Exception when attempting to use the org.mockito.ArgumentMatchers.eq function to mock a call. Code example:

      doReturn(responseEntity)
              .when(restTemplate)
              .exchange(
                  anyString(),
                  eq(HttpMethod.POST),
                  any(HttpEntity.class),
                  eq(new ParameterizedTypeReference<>() {}));

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Compilation works, or I am given the correct warning about why the code cannot compile
      ACTUAL -
      Compilation process errors out

      FREQUENCY : always


            adev Anupam Dev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: