Forum: JRuby mysterious closed stream (IOError) exception

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Josh M. (Guest)
on 2009-04-01 18:24
(Received via mailing list)
Hi,  Sorry to keep bothering everybody with what are probably very
beginnerish questions.  Thanks to everybody who has already helped me
out in
answering questions.  This time I am complete mystified as to what is
going
own.  The parse_input(input, output) function some how closes STDOUT.
Because "puts "71"" works fine but the "puts "100"" statement files with
a
closed stream exception.  When the function is called input=ARGF and
output=$stdout.  I am to much of a new person to be able to figure out
what
is causing the closed stream exception.  All that I do know is that it
is
somewhere in this function and that this code works fine in the MRI.  I
will
be happy to personally keep working on this code to figure out what is
broken if I can get some pointers on where and what to look for.  Thanks
so
much in advance for all the help.

Josh

  def parse_input(input, output)
    current = []
    data = []
    data << current
    print_lines = true
    term = "\nFinished".split(//).map { |c| c[0] }
    term_length = term.size

    old_sync = output.sync
    output.sync = true
puts  "71"
    while line = input.gets
      case line
      when /^(Loaded suite|Started)/ then
        print_lines = true
        output.puts line
        chars = []
        while c = input.getc do
          output.putc c
          chars << c
          tail = chars[-term_length..-1]
          break if chars.size >= term_length and tail == term
        end
        output.puts input.gets # the rest of "Finished in..."
        output.puts
       next
      when /^\s*$/, /^\(?\s*\d+\) (Failure|Error):/, /^\d+\)/ then
        print_lines = false
        current = []
        data << current
      when /^Finished in \d/ then
        print_lines = false
      end
      output.puts line if print_lines
      current << line
    end
    output.sync = old_sync
    data = data.reject { |o| o == ["\n"] or o.empty? }
    footer = data.pop
puts "100"
    return data, footer
  end
Charles Oliver N. (Guest)
on 2009-04-02 02:36
(Received via mailing list)
Josh M. wrote:
> on this code to figure out what is broken if I can get some pointers on
> where and what to look for.  Thanks so much in advance for all the help.

Well keep trying to narrow it down, but the only thing that seems to
have any potential for causing this is the output.sync call. I'm a bit
confused myself though...

- Charlie

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email
This topic is locked and can not be replied to.