You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by "Gary Gregory (JIRA)" <ji...@apache.org> on 2016/01/26 22:03:39 UTC
[jira] [Commented] (HTTPCLIENT-1715) NTLMEngineImpl.Type1Message
not thread safe but declared as a constant
[ https://issues.apache.org/jira/browse/HTTPCLIENT-1715?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15118014#comment-15118014 ]
Gary Gregory commented on HTTPCLIENT-1715:
------------------------------------------
Something like this perhaps:
{code:none}
### Eclipse Workspace Patch 1.0
#P httpclient5
Index: src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java
===================================================================
--- src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java (revision 1726895)
+++ src/main/java/org/apache/hc/client5/http/impl/auth/NTLMEngineImpl.java (working copy)
@@ -98,7 +98,7 @@
SIGNATURE[bytesWithoutNull.length] = (byte) 0x00;
}
- private static final Type1Message TYPE_1_MESSAGE = new Type1Message();
+ private static final String TYPE_1_MESSAGE = new Type1Message().getResponse();
/**
* Returns the response for the given message.
@@ -145,7 +145,7 @@
static String getType1Message(final String host, final String domain) {
// For compatibility reason do not include domain and host in type 1 message
//return new Type1Message(domain, host).getResponse();
- return TYPE_1_MESSAGE.getResponse();
+ return TYPE_1_MESSAGE;
}
/**
{code}
Unless we can make the superclass thread safe, which would be generally more useful.
> NTLMEngineImpl.Type1Message not thread safe but declared as a constant
> ----------------------------------------------------------------------
>
> Key: HTTPCLIENT-1715
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-1715
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpClient
> Affects Versions: 4.5.1
> Reporter: Olivier Lafontaine
>
> {{NTLMEngineImpl}} declares a {{static final}} member named {{TYPE_1_MESSAGE}} of type {{Type1Message}}. Members of {{Type1Message}} are final and do not change, but that is not the case for members of its superclass {{NTLMMessage}}.
> Whenever the method {{NTLMEngineImpl#getType1Message(String, String)}} is called, the method {{NTLMMessage#getResponse()}} get called on the {{TYPE_1_MESSAGE}} instance and this modifies the following members of {{NTLMMessage}}:
> * messageContents
> * currentOutputPosition
> This is not thread safe and we get exceptions as seen in HTTPCLIENT-1686.
> My guess is that the computed response string should be kept in a constant instead of a {{Type1Message}} instance.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org