commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CODEC-232) URLCodec is neither immutable nor threadsafe
Date Tue, 28 Mar 2017 13:51:42 GMT
Sebb created CODEC-232:
--------------------------

             Summary: URLCodec is neither immutable nor threadsafe
                 Key: CODEC-232
                 URL: https://issues.apache.org/jira/browse/CODEC-232
             Project: Commons Codec
          Issue Type: Bug
            Reporter: Sebb


URLCodec Javadoc says the class is immutable and threadsafe.

However it is not immutable, because of the fields:

protected static final BitSet WWW_FORM_URL;
protected String charset;

Nor is it threadsafe, because external code can change the charset field; changes to the field
are not safely published across threads.

(The WWW_FORM_URL field is no longer used internally).

The class could be made effectively immutable (and threadsafe) by also saving the initial
charset name in a private final field and only using the private field.

Or the charset field could be made volatile.
This would preserve the behaviour for subclasses that rely on changing the charset field.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message