You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Sebb (JIRA)" <ji...@apache.org> on 2008/04/08 12:21:24 UTC

[jira] Created: (NET-213) Unsafe code in FromNetASCIIInputStream.java

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.


[jira] Resolved: (NET-213) Unsafe code in FromNetASCIIInputStream.java

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb resolved NET-213.
----------------------

    Resolution: Fixed

> 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: 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.


[jira] Commented: (NET-213) Unsafe code in FromNetASCIIInputStream.java

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Commented: (NET-213) Unsafe code in FromNetASCIIInputStream.java

Posted by "Sebb (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/NET-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12586878#action_12586878 ] 

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

Reverted the code back to the way that 1.5 does it.

http://svn.apache.org/viewvc?rev=645995&view=rev

> 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: 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.


[jira] Updated: (NET-213) Unsafe code in FromNetASCIIInputStream.java

Posted by "Sebb (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/NET-213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sebb updated NET-213:
---------------------

    Fix Version/s:     (was: 1.5)

Does not apply to 1.5

> 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: 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.