jersey
  1. jersey
  2. JERSEY-2374

NullPointerException in OAuth1ClientFeature

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.5.1
    • Fix Version/s: 2.6
    • Component/s: core
    • Labels:
      None

      Description

      OAuth1ClientFeature has a ServiceLocator instance that should be injected:

      @Inject
      private ServiceLocator config;
      

      However, this config is not used in the class. Also, the injection fails and the config is null. This object is printed in the configure method:

      public boolean configure(FeatureContext context) {
      System.out.println(config);
      ...
      }
      

      In GlassFish, this causes a NullPointerException:
      java.lang.NullPointerException
      at com.sun.common.util.logging.LoggingOutputStream$LoggingPrintStream.println(LoggingOutputStream.java:230)
      at org.apache.felix.gogo.runtime.threadio.ThreadPrintStream.println(ThreadPrintStream.java:208)
      at org.glassfish.jersey.client.oauth1.OAuth1ClientFeature.configure(OAuth1ClientFeature.java:100)

      LoggingOutputStream will try to print config.toString().

      Solution: since the config field is not used, it should be removed at all. I propose the following patch:

      diff --git a/security/oauth1-client/src/main/java/org/glassfish/jersey/client/oauth1/OAuth1ClientFeature.java b/security/oauth1-client/src/main/java/org/glassfish/jersey/client/oauth1/OAut
      index c219e90..a45f8de 100644
      --- a/security/oauth1-client/src/main/java/org/glassfish/jersey/client/oauth1/OAuth1ClientFeature.java
      +++ b/security/oauth1-client/src/main/java/org/glassfish/jersey/client/oauth1/OAuth1ClientFeature.java
      @@ -81,9 +81,6 @@ final class OAuth1ClientFeature implements Feature {
           private final OAuth1Parameters parameters;
           private final OAuth1Secrets secrets;
       
      -    @Inject
      -    private ServiceLocator config;
      -
           /**
            * Create a new feature.
            *
      @@ -97,7 +94,6 @@ final class OAuth1ClientFeature implements Feature {
       
           @Override
           public boolean configure(FeatureContext context) {
      -        System.out.println(config);
       
               context.register(OAuth1SignatureFeature.class);
               context.register(OAuth1ClientFilter.class);
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            Miroslav Fuksa
            Reporter:
            johanvos
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: