BasicSocket#close_read and #close_write not working ---------------------------------------------------
Key: JRUBY-2672 URL: http://jira.codehaus.org/browse/JRUBY-2672 Project: JRuby Issue Type: Bug Components: Core Classes/Modules Environment: Mac OS 10.5.3 Reporter: Federico Builes The following's a sample jirb session to try out #close_read: {noformat} $ jirb irb(main):001:0> require 'socket' require 'socket' => true irb(main):002:0> s = TCPServer.new(2345) s = TCPServer.new(2345) => #<TCPServer:0x88c838> irb(main):003:0> s.close_read s.close_read => #<TCPServer:0x88c838> irb(main):004:0> s.closed? s.closed? => false irb(main):005:0> s.close s.close Errno::EBADF: Bad file descriptor - Bad file descriptor {noformat} The situation with #close_write is a bit longer: {noformat} $ jirb irb(main):001:0> require 'socket' require 'socket' => true irb(main):002:0> s = TCPServer.new(2345) s = TCPServer.new(2345) => #<TCPServer:0x88c838> irb(main):003:0> s.close_write s.close_write Exception in thread "main" java.lang.ClassCastException: sun.nio.ch.ServerSocketChannelImpl at org.jruby.ext.socket.RubyBasicSocket.close_write(RubyBasicSocket.java:94) at org.jruby.RubyIOInvoker$close_write_method_0_0.call(Unknown Source) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:121) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:326) at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:57) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.RootNode.interpret(RootNode.java:126) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.evaluator.ASTInterpreter.evalWithBinding(ASTInterpreter.java:140) at org.jruby.RubyKernel.eval(RubyKernel.java:813) at org.jruby.RubyKernelInvoker$eval_s_method_0_3.call(Unknown Source) at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:293) at org.jruby.ast.FCallNode.interpret(FCallNode.java:164) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:204) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:293) at org.jruby.ast.CallNode.interpret(CallNode.java:177) at org.jruby.ast.FCallOneArgNode.interpret(FCallOneArgNode.java:43) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:309) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:383) at org.jruby.ast.CallTwoArgNode.interpret(CallTwoArgNode.java:59) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.ast.RescueNode.interpret(RescueNode.java:109) at org.jruby.ast.BeginNode.interpret(BeginNode.java:80) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:206) at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:192) at org.jruby.runtime.Block.yield(Block.java:103) at org.jruby.ast.YieldNode.interpret(YieldNode.java:95) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.EnsureNode.interpret(EnsureNode.java:93) at org.jruby.ast.BeginNode.interpret(BeginNode.java:80) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:288) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:365) at org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:38) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:206) at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:192) at org.jruby.runtime.Block.yield(Block.java:103) at org.jruby.ast.YieldNode.interpret(YieldNode.java:95) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.IfNode.interpret(IfNode.java:108) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.ast.RescueNode.interpret(RescueNode.java:109) at org.jruby.ast.BeginNode.interpret(BeginNode.java:80) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:206) at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:153) at org.jruby.runtime.Block.yield(Block.java:98) at org.jruby.RubyKernel.loop(RubyKernel.java:1000) at org.jruby.RubyKernelInvoker$loop_s_method_0_0.call(Unknown Source) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:135) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:338) at org.jruby.ast.FCallNoArgBlockNode.interpret(FCallNoArgBlockNode.java:38) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:206) at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:153) at org.jruby.runtime.Block.yield(Block.java:98) at org.jruby.RubyKernel.rbCatch(RubyKernel.java:841) at org.jruby.RubyKernelInvoker$rbCatch_s_method_1_0.call(Unknown Source) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:163) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:368) at org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:38) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:246) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:135) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:338) at org.jruby.ast.CallNoArgBlockNode.interpret(CallNoArgBlockNode.java:64) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:225) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:121) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:326) at org.jruby.ast.CallNoArgNode.interpret(CallNoArgNode.java:57) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.runtime.InterpretedBlock.evalBlockBody(InterpretedBlock.java:206) at org.jruby.runtime.InterpretedBlock.yield(InterpretedBlock.java:153) at org.jruby.runtime.Block.yield(Block.java:98) at org.jruby.RubyKernel.rbCatch(RubyKernel.java:841) at org.jruby.RubyKernelInvoker$rbCatch_s_method_1_0.call(Unknown Source) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:163) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:368) at org.jruby.ast.FCallOneArgBlockNode.interpret(FCallOneArgBlockNode.java:38) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:99) at org.jruby.ast.BlockNode.interpret(BlockNode.java:67) at org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:87) at org.jruby.internal.runtime.methods.DefaultMethod.interpretedCall(DefaultMethod.java:174) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:150) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:267) at org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:149) at org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:356) at ruby.Users.federicobuiles.programacion.jruby.bin.jirb.__file__(/Users/federicobuiles/programacion/jruby/bin/jirb:19) at ruby.Users.federicobuiles.programacion.jruby.bin.jirb.__file__(/Users/federicobuiles/programacion/jruby/bin/jirb) at ruby.Users.federicobuiles.programacion.jruby.bin.jirb.load(/Users/federicobuiles/programacion/jruby/bin/jirb) at org.jruby.Ruby.runScript(Ruby.java:520) at org.jruby.Ruby.runNormally(Ruby.java:440) at org.jruby.Ruby.runFromMain(Ruby.java:320) at org.jruby.Main.run(Main.java:184) at org.jruby.Main.run(Main.java:91) at org.jruby.Main.main(Main.java:82) {noformat} Both of these cases are included in Rubyspec in: /spec/ruby/1.8/library/socket/basicsocket/close_{read|write}_spec.rb in case you want to try this out. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email