You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that the given script (at bottom) now produces NPE when run.
What steps will reproduce the problem?
Run the attached script test.rb
What is the expected output? What do you see instead?
I would expect output to be redirected like in MRI.
Additional information
jruby 1.6.7.2
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
jruby 1.6.7.2 --1.9
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
jruby 1.7.1 (1.9.3p327)
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
jruby 1.7.2.dev (1.9.3p327) 2013-01-02 (rvm install jruby-head) fffffff on Java HotSpot(TM) 64-Bit Server VM 1.6.0_37-b06-434-11M3909 [darwin-x86_64]
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
ruby 1.9.3-p194
I, [2013-01-02T14:10:19.076856 #53379] INFO -- : INTERCEPTED: Should be intercepted
I, [2013-01-02T14:10:19.077363 #53379] INFO -- : INTERCEPTED:
Should not be intercepted
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
I, [2013-01-02T14:14:51.521904 #53685] INFO -- : INTERCEPTED: Should be intercepted
I, [2013-01-02T14:14:51.553957 #53685] INFO -- : INTERCEPTED:
This is confirmed working properly on master (9k) but still broken in JRuby 1.7. Because the original report was so long ago and it works on the newer branch, I'm going to mark this fixed in 9k.pre2.
The NPE is caused by our $stdout assignment logic, which sees that the incoming object is an IO, so it tries to treat it like an IO. However, it has not been initialized with proper streams and is not really a functional IO in any way other than that it has a working #write method.
This sort of masquerading as a native class will always lead to trouble, especially when you're short-circuiting the initialization process and preventing the superclass from properly setting the object up. I dare say this is also a violation of LSP, since the reporter's specialized IO subclass could no longer be fully functional as an IO.
Nevertheless, we shouldn't fail to hook up the fake stream here, and I'll see if I can't improve that.
With the NPE fixed, it appears JRuby 1.7 actually does the right thing now too. Hooplah!
[] ~/projects/jruby-1.7 $ jruby ../jruby/blah.rb
I, [2015-05-04T15:19:55.640000 #14373] INFO -- : INTERCEPTED: Should be intercepted
I, [2015-05-04T15:19:55.837000 #14373] INFO -- : INTERCEPTED:
Should not be intercepted
From http://jira.codehaus.org/browse/JRUBY-7051
Note that the given script (at bottom) now produces NPE when run.
What steps will reproduce the problem?
Run the attached script test.rb
What is the expected output? What do you see instead?
I would expect output to be redirected like in MRI.
Additional information
jruby 1.6.7.2
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
jruby 1.6.7.2 --1.9
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
jruby 1.7.1 (1.9.3p327)
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
jruby 1.7.2.dev (1.9.3p327) 2013-01-02 (rvm install jruby-head) fffffff on Java HotSpot(TM) 64-Bit Server VM 1.6.0_37-b06-434-11M3909 [darwin-x86_64]
Errno::EBADF: Bad file descriptor - Bad file descriptor
(root) at test.rb:14
ruby 1.9.3-p194
I, [2013-01-02T14:10:19.076856 #53379] INFO -- : INTERCEPTED: Should be intercepted
I, [2013-01-02T14:10:19.077363 #53379] INFO -- : INTERCEPTED:
Should not be intercepted
ruby 1.8.7 (2011-12-28 patchlevel 357) [universal-darwin11.0]
I, [2013-01-02T14:14:51.521904 #53685] INFO -- : INTERCEPTED: Should be intercepted
I, [2013-01-02T14:14:51.553957 #53685] INFO -- : INTERCEPTED:
Should not be intercepted
Script from original issue: https://gist.github.com/headius/e0ecd58485e2b4ca4938
The text was updated successfully, but these errors were encountered: