Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-1652

AuthSchemeBase.challengeState doesn't survive serialisation in BasicAuthCache

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 4.4.1
    • 4.5
    • HttpClient (classic)
    • None

    Description

      If a BasicScheme with ChallengeState defined is put in a BasicAuthCache, it comes out of the cache with null challengeState.

      This is a small test to demonstrate the problem:

          @Test
          public void assertChallengeStateSurvivesSerialisation() throws Exception {
              BasicAuthCache localCache = new BasicAuthCache();
              HttpHost aHost = new HttpHost("sample.host", 80);
      
              BasicScheme proxyScheme = new BasicScheme();
              proxyScheme.processChallenge(
                      new BasicHeader(HttpHeaders.PROXY_AUTHENTICATE, "Basic "));
      
              assertThat(proxyScheme.getChallengeState(), is(ChallengeState.PROXY));
      
              localCache.put(aHost, proxyScheme);
      
              BasicScheme outOfCache = (BasicScheme) localCache.get(aHost);
              assertThat(outOfCache.getChallengeState(), is(ChallengeState.PROXY));
          }
      

      result is:

      java.lang.AssertionError: 
      Expected: is <PROXY>
           but: was null
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rsabitov Renat Sabitov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: