JRuby

Text that comes out of Java APIs mixes poorly with text that doesn't

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: JRuby 0.9.0
  • Fix Version/s: JRuby 0.9.9
  • Component/s: Java Integration
  • Labels:
    None
  • Environment:
    Latest Ubuntu, Java 1.5.0_06, latest JRuby
  • Number of attachments :
    3

Description

If I build up a string in JRuby, some of which comes out of the Java libraries, there are anomalies. In the attached file I parse a chunk of XML then serialize it again out of the DOM. It contains some non-ASCII characters. If I puts it to STDOUT, it is converted to UTF-8. If I write it to a file, it is apparently broken.

  1. jrexml.rb
    07/Aug/06 1:41 PM
    7 kB
    Tim Bray
  2. jruby_seekable_io.patch
    07/Aug/06 10:01 PM
    0.5 kB
    Thomas E Enebo
  3. t.rb
    07/Aug/06 1:41 PM
    0.3 kB
    Tim Bray

Activity

Hide
Thomas E Enebo added a comment -

This patch does fix your test case and also allows ant test to run. Unfortunately, it breaks rubygems.

Show
Thomas E Enebo added a comment - This patch does fix your test case and also allows ant test to run. Unfortunately, it breaks rubygems.
Hide
Thomas E Enebo added a comment -

I have a patch which fixes your problem attached. It also runs ant test fine. However, it dies in RubyGems and it is getting late for me; So I figured I may as well dump what I have right now.

Show
Thomas E Enebo added a comment - I have a patch which fixes your problem attached. It also runs ant test fine. However, it dies in RubyGems and it is getting late for me; So I figured I may as well dump what I have right now.
Hide
Charles Oliver Nutter added a comment -

Tom, you started a fix...got some time to wrap up the last minor issues?

Show
Charles Oliver Nutter added a comment - Tom, you started a fix...got some time to wrap up the last minor issues?
Hide
Charles Oliver Nutter added a comment -

This could actually be a larger issue now that we have a byte[]-based String impl. We need to address interop before 1.0, which means it should be in for 0.9.9.

Show
Charles Oliver Nutter added a comment - This could actually be a larger issue now that we have a byte[]-based String impl. We need to address interop before 1.0, which means it should be in for 0.9.9.
Hide
Charles Oliver Nutter added a comment -

If there was an encoding problem before, it doesn't seem to be present anymore. However it seems like this may now be an issue of when to flush a file. If I change the code in t.rb from this:

File.new("rd-bug", "w").write(e)

to this:

File.open("rd-bug", "w") {|f| f.write(e)}

The file contents match the stdout output. This tells me that a bare write on an open file, without an explicit close, does not get flushed to disk. Correct Ruby behavior appears to be that streams should close and flush on exit. I will file that as a separate bug.

Show
Charles Oliver Nutter added a comment - If there was an encoding problem before, it doesn't seem to be present anymore. However it seems like this may now be an issue of when to flush a file. If I change the code in t.rb from this: File.new("rd-bug", "w").write(e) to this: File.open("rd-bug", "w") {|f| f.write(e)} The file contents match the stdout output. This tells me that a bare write on an open file, without an explicit close, does not get flushed to disk. Correct Ruby behavior appears to be that streams should close and flush on exit. I will file that as a separate bug.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: