You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Keegan Witt <ke...@gmail.com> on 2015/08/18 16:42:50 UTC

Unexpected Path.write(text, charset) behavior

So, I was working on GROOVY-7465
<https://issues.apache.org/jira/browse/GROOVY-7465> when I noticed
something peculiar.

def p = java.nio.file.Paths.get("foo.txt")
p.write("1")
p.write("2")
assert p.text == "2"  // passes
java.nio.file.Files.delete(p)
p.write("1", "UTF-8")
p.write("2", "UTF-8")
assert p.text == "2"  // fails, is '12'
java.nio.file.Files.delete(p)

While 7465 is targeting 2.5.0, I'm wondering if I should fix this in
2.4.5?  If agreed, I'll open a separate Jira for this issue.

-Keegan

Re: Unexpected Path.write(text, charset) behavior

Posted by Keegan Witt <ke...@gmail.com>.
I'm doing some refactoring to remove code duplication (and adding more unit
tests) as part of 7465 to hopefully prevent issues like this going
forward.  But for now, I'll keep it simple:
https://github.com/apache/incubator-groovy/pull/89

-Keegan

On Wed, Aug 19, 2015 at 9:40 AM, Keegan Witt <ke...@gmail.com> wrote:

> OK.  I felt like this was different than 7465 because it's more of a bug
> rather than an inconsistency, but I hesitated on putting in 2.4.5 because
> theoretically someone could be relying on the current behavior.  I opened
> GROOVY-7553 <https://issues.apache.org/jira/browse/GROOVY-7553> for this.
>
> -Keegan
>
> On Wed, Aug 19, 2015 at 3:50 AM, Guillaume Laforge <gl...@gmail.com>
> wrote:
>
>> +1
>> Le 19 août 2015 09:21, "Paolo Di Tommaso" <pa...@gmail.com> a
>> écrit :
>>
>>> I think it's a good idea.
>>>
>>>
>>> Cheers,
>>> Paolo
>>>
>>>
>>> On Tue, Aug 18, 2015 at 4:42 PM, Keegan Witt <ke...@gmail.com>
>>> wrote:
>>>
>>>> So, I was working on GROOVY-7465
>>>> <https://issues.apache.org/jira/browse/GROOVY-7465> when I noticed
>>>> something peculiar.
>>>>
>>>> def p = java.nio.file.Paths.get("foo.txt")
>>>> p.write("1")
>>>> p.write("2")
>>>> assert p.text == "2"  // passes
>>>> java.nio.file.Files.delete(p)
>>>> p.write("1", "UTF-8")
>>>> p.write("2", "UTF-8")
>>>> assert p.text == "2"  // fails, is '12'
>>>> java.nio.file.Files.delete(p)
>>>>
>>>> While 7465 is targeting 2.5.0, I'm wondering if I should fix this in
>>>> 2.4.5?  If agreed, I'll open a separate Jira for this issue.
>>>>
>>>> -Keegan
>>>>
>>>
>>>
>

Re: Unexpected Path.write(text, charset) behavior

Posted by Keegan Witt <ke...@gmail.com>.
OK.  I felt like this was different than 7465 because it's more of a bug
rather than an inconsistency, but I hesitated on putting in 2.4.5 because
theoretically someone could be relying on the current behavior.  I opened
GROOVY-7553 <https://issues.apache.org/jira/browse/GROOVY-7553> for this.

-Keegan

On Wed, Aug 19, 2015 at 3:50 AM, Guillaume Laforge <gl...@gmail.com>
wrote:

> +1
> Le 19 août 2015 09:21, "Paolo Di Tommaso" <pa...@gmail.com> a
> écrit :
>
>> I think it's a good idea.
>>
>>
>> Cheers,
>> Paolo
>>
>>
>> On Tue, Aug 18, 2015 at 4:42 PM, Keegan Witt <ke...@gmail.com>
>> wrote:
>>
>>> So, I was working on GROOVY-7465
>>> <https://issues.apache.org/jira/browse/GROOVY-7465> when I noticed
>>> something peculiar.
>>>
>>> def p = java.nio.file.Paths.get("foo.txt")
>>> p.write("1")
>>> p.write("2")
>>> assert p.text == "2"  // passes
>>> java.nio.file.Files.delete(p)
>>> p.write("1", "UTF-8")
>>> p.write("2", "UTF-8")
>>> assert p.text == "2"  // fails, is '12'
>>> java.nio.file.Files.delete(p)
>>>
>>> While 7465 is targeting 2.5.0, I'm wondering if I should fix this in
>>> 2.4.5?  If agreed, I'll open a separate Jira for this issue.
>>>
>>> -Keegan
>>>
>>
>>

Re: Unexpected Path.write(text, charset) behavior

Posted by Guillaume Laforge <gl...@gmail.com>.
+1
Le 19 août 2015 09:21, "Paolo Di Tommaso" <pa...@gmail.com> a
écrit :

> I think it's a good idea.
>
>
> Cheers,
> Paolo
>
>
> On Tue, Aug 18, 2015 at 4:42 PM, Keegan Witt <ke...@gmail.com> wrote:
>
>> So, I was working on GROOVY-7465
>> <https://issues.apache.org/jira/browse/GROOVY-7465> when I noticed
>> something peculiar.
>>
>> def p = java.nio.file.Paths.get("foo.txt")
>> p.write("1")
>> p.write("2")
>> assert p.text == "2"  // passes
>> java.nio.file.Files.delete(p)
>> p.write("1", "UTF-8")
>> p.write("2", "UTF-8")
>> assert p.text == "2"  // fails, is '12'
>> java.nio.file.Files.delete(p)
>>
>> While 7465 is targeting 2.5.0, I'm wondering if I should fix this in
>> 2.4.5?  If agreed, I'll open a separate Jira for this issue.
>>
>> -Keegan
>>
>
>

Re: Unexpected Path.write(text, charset) behavior

Posted by Paolo Di Tommaso <pa...@gmail.com>.
I think it's a good idea.


Cheers,
Paolo


On Tue, Aug 18, 2015 at 4:42 PM, Keegan Witt <ke...@gmail.com> wrote:

> So, I was working on GROOVY-7465
> <https://issues.apache.org/jira/browse/GROOVY-7465> when I noticed
> something peculiar.
>
> def p = java.nio.file.Paths.get("foo.txt")
> p.write("1")
> p.write("2")
> assert p.text == "2"  // passes
> java.nio.file.Files.delete(p)
> p.write("1", "UTF-8")
> p.write("2", "UTF-8")
> assert p.text == "2"  // fails, is '12'
> java.nio.file.Files.delete(p)
>
> While 7465 is targeting 2.5.0, I'm wondering if I should fix this in
> 2.4.5?  If agreed, I'll open a separate Jira for this issue.
>
> -Keegan
>