Index: httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8 =================================================================== --- httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java (revision 460b60607d7c423db04aa72665fcdc1e164fc1a0) +++ httpclient/src/main/java/org/apache/http/impl/auth/NTLMScheme.java (date 1525437975000) @@ -147,7 +147,9 @@ this.challenge); this.state = State.MSG_TYPE3_GENERATED; } else { - throw new AuthenticationException("Unexpected state: " + this.state); + final State invalidState = this.state; + resetContext(); + throw new AuthenticationException("Unexpected state: " + invalidState); } final CharArrayBuffer buffer = new CharArrayBuffer(32); if (isProxy()) { @@ -165,4 +167,8 @@ return this.state == State.MSG_TYPE3_GENERATED || this.state == State.FAILED; } + private void resetContext() { + this.state = State.UNINITIATED; + this.challenge = null; + } }