Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.6.6, JRuby 1.6.7
-
Fix Version/s: JRuby 1.7.0.pre1
-
Component/s: Core Classes/Modules
-
Labels:
-
Environment:Mac OSX 10.7.3
-
Number of attachments :
Description
The following code works and returns the root node on any version of JRuby prior to 1.6.6:
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
As of JRuby 1.6.6 the last line above returns nil.
Below is the output from JRuby 1.6.5:
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 ....
On JRuby 1.6.6 (similarly for JRuby 1.6.7) :
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
Java version output:
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)
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
Activity
| Field | Original Value | New Value |
|---|---|---|
| Attachment | rexml.diff [ 59693 ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Assignee | Charles Oliver Nutter [ headius ] | |
| Fix Version/s | JRuby 1.7 [ 17049 ] | |
| Fix Version/s | JRuby 1.6.8 [ 18345 ] | |
| Resolution | Fixed [ 1 ] |