JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-1897

Tailing a file with file-tail blows up with EOF when the file gets truncated

    Details

    • Number of attachments :
      0

      Description

      Reported on IRC:

      /opt/local/jruby-1.1b1/lib/ruby/gems/1.8/gems/file-tail-1.0.2/lib/file/tail.rb:300:in `loop': End of file reached (EOFError)
      	from /opt/local/jruby-1.1b1/lib/ruby/gems/1.8/gems/file-tail-1.0.2/lib/file/tail.rb:300:in `tail'
      	from /opt/local/jruby-1.1b1/lib/ruby/gems/1.8/gems/file-tail-1.0.2/lib/file/tail.rb:300:in `tail'
      	from script/logmonster:26:in `open'
      	from /opt/local/jruby-1.1b1/lib/ruby/gems/1.8/gems/file-tail-1.0.2/lib/file/tail.rb:101:in `open'
      
      To reproduce: tail a file with lines in it (tail advances file pointer to max), truncate file
      

        Activity

        Hide
        Ola Bini added a comment -

        Can you either give us a script that reproduces this behavior, or try again with current trunk? Charles has reworked the IO subsystem lately, and it might well already be fixed.

        Show
        Ola Bini added a comment - Can you either give us a script that reproduces this behavior, or try again with current trunk? Charles has reworked the IO subsystem lately, and it might well already be fixed.
        Hide
        Charles Oliver Nutter added a comment -

        Punting issues from 1.1 RC2 to 1.1 final.

        Show
        Charles Oliver Nutter added a comment - Punting issues from 1.1 RC2 to 1.1 final.
        Hide
        Charles Oliver Nutter added a comment -

        A test case for the bug, which does appear to still be failing:

        require 'test/unit'
        require 'fileutils'
        
        class Test1897 < Test::Unit::TestCase
          def setup
            FileUtils.rm_f("test.file")rescue nil
          end
          def teardown
            FileUtils.rm_f("test.file")rescue nil
          end
          def test_1897
            File.open("test.file", 'w') do |f|
              0.upto(100){|n|f.write(n)}
            end
            a = Thread.new do
              File.open("test.file") do |f|
                f.seek(IO::SEEK_END)
                0.upto(50) do
                  f.readline
                  puts "sleepin'"
                  sleep 1
                  puts "awoke"
                end
              end
            end
        
            b =Thread.new do
              0.upto(500) do
                if a.status != 'run'
                  puts "deleting file while a is sleepin'"
                  FileUtils.rm_f("test.file")
                  break
                  sleep 1
                end
              end
            end
            b.join
            a.join
          end
        end
        
        Show
        Charles Oliver Nutter added a comment - A test case for the bug, which does appear to still be failing: require 'test/unit' require 'fileutils' class Test1897 < Test::Unit::TestCase def setup FileUtils.rm_f( "test.file" )rescue nil end def teardown FileUtils.rm_f( "test.file" )rescue nil end def test_1897 File.open( "test.file" , 'w') do |f| 0.upto(100){|n|f.write(n)} end a = Thread . new do File.open( "test.file" ) do |f| f.seek(IO::SEEK_END) 0.upto(50) do f.readline puts "sleepin'" sleep 1 puts "awoke" end end end b = Thread . new do 0.upto(500) do if a.status != 'run' puts "deleting file while a is sleepin'" FileUtils.rm_f( "test.file" ) break sleep 1 end end end b.join a.join end end
        Hide
        Thomas E Enebo added a comment -

        The unit test provided fails under current version of MRI and JRuby. Resolving.

        Show
        Thomas E Enebo added a comment - The unit test provided fails under current version of MRI and JRuby. Resolving.
        Hide
        Charles Oliver Nutter added a comment -

        Migrating bugs marked as resolved before 1.1RC3 and tagged as version 1.1 as fixed in RC3. Only two bugs are actually fixed between RC3 and 1.1

        Show
        Charles Oliver Nutter added a comment - Migrating bugs marked as resolved before 1.1RC3 and tagged as version 1.1 as fixed in RC3. Only two bugs are actually fixed between RC3 and 1.1

          People

          • Assignee:
            Unassigned
            Reporter:
            Charles Oliver Nutter
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: