[ 
https://issues.apache.org/jira/browse/NET-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586744#action_12586744
 ] 

Sebb commented on NET-213:
--------------------------

Just noticed another problem: the contructor uses the length of the field 
_lineSeparatorBytes *before* assigning to it.

I think it's highly unlikely that the line separator value will ever require 
different bytes in different encodings.
However, if it does, then using a static field is not the correct way to 
communicate the value to the FromNetASCIIOutputStream class.

> Unsafe code in FromNetASCIIInputStream.java
> -------------------------------------------
>
>                 Key: NET-213
>                 URL: https://issues.apache.org/jira/browse/NET-213
>             Project: Commons Net
>          Issue Type: Bug
>            Reporter: Sebb
>             Fix For: 1.5, 2.0
>
>
> The constructors in FromNetASCIIInputStream.java assign a value to a static 
> field:
> _lineSeparatorBytes = _lineSeparator.getBytes(encoding);
> This is not thread-safe, indeed it is thread-hostile if the value can ever be 
> different for different encodings.
> (Two different instances wanting to use two different values of the same 
> static field)
> The field should be initialised in the static initialiser (and should 
> probably be made final as a hint not to change it - though this won't stop 
> the contents being changed).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to