Reid Morrison created JRUBY-6517:
------------------------------------
Summary: StringIO#ungetc issue on JRuby 1.6.6 and 1.6.7 in 1.8.7
mode
Key: JRUBY-6517
URL: https://jira.codehaus.org/browse/JRUBY-6517
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.6.6, JRuby 1.6.7
Environment: Mac OSX 10.7.3
Reporter: Reid Morrison
Fix For: JRuby 1.6.8
The following code works and returns the root node on any version of JRuby
prior to 1.6.6:
{quote}
require 'stringio'
require 'rexml/document'
str = "<?xml version=\"1.0\"?>\n<xdoc>\n\t<errorcode>0</errorcode>\n</xdoc>"
data = StringIO.new(str)
char = data.getc
data.ungetc(char)
REXML::Document.new(data).root
{quote}
As of JRuby 1.6.6 the last line above returns nil.
Below is the output from JRuby 1.6.5:
{quote}
jruby -v -S irb
jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (Java HotSpot(TM) 64-Bit
Server VM 1.6.0_29) [darwin-x86_64-java]
>> require 'stringio'
=> true
>> require 'rexml/document'
=> true
>> str = "<?xml version=\"1.0\"?>\n<xdoc>\n\t<errorcode>0</errorcode>\n</xdoc>"
=> "<?xml version="1.0"?>\n<xdoc>\n\t<errorcode>0</errorcode>\n</xdoc>"
>> data = StringIO.new(str)
=> #<StringIO:0x28c13406>
>>
?> char = data.getc
=> 60
>> data.ungetc(char)
=> nil
>>
?> REXML::Document.new(data).root
=> *xdoc* ....
{quote}
On JRuby 1.6.6 (similarly for JRuby 1.6.7) :
{quote}
jruby -v -S irb
jruby 1.6.6 (ruby-1.8.7-p357) (2012-01-30 5673572) (Java HotSpot(TM) 64-Bit
Server VM 1.6.0_29) [darwin-x86_64-java]
>> require 'stringio'
=> true
>> require 'rexml/document'
=> true
>> str = "<?xml version=\"1.0\"?>\n<xdoc>\n\t<errorcode>0</errorcode>\n</xdoc>"
=> "<?xml version="1.0"?>\n<xdoc>\n\t<errorcode>0</errorcode>\n</xdoc>"
>> data = StringIO.new(str)
=> #<StringIO:0x539ff66f>
>>
?> char = data.getc
=> 60
>> data.ungetc(char)
=> nil
>>
?> REXML::Document.new(data).root
=> *nil*
{quote}
Java version output:
{quote}
java -version
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-11D50)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
{quote}
The above code is a subset of the code in Rails 3.0.10 to reproduce the issue
in a standalone environment. It is occurring under ActiveSupport::XmlMini.parse
which is using REXML by default
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.codehaus.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email