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

AuthSchemeBase.challengeState doesn't survive serialisation in BasicAuthCache

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 4.4.1
    • Fix Version/s: 4.5
    • Component/s: HttpClient (classic)
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: