Project

General

Profile

Actions

Defect #19091

closed

SCM integration broken with JRuby (partial fix)

Added by Matthew Bloch about 10 years ago. Updated almost 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
SCM
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Wont fix
Affected version:

Description

When running Redmine (2.6.1) under JRuby (1.7.19), the SCM integration is broken due to a long-standing problem with JRuby and IO.popen's "r+" mode (described at https://github.com/jruby/jruby/issues/779).

It shows up in the front-end as a 500 error and the external command reporting "Bad file descriptor".

As far as I understand it this can't be fixed without some changes to Java, but we can avoid triggering the bug by not using the r+ mode unnecessarily.

In lib/redmine/scm/adapters/abstract_adapter.rb:254 in the "shellout" method we have this code:

mode = "r+" 
IO.popen(cmd, mode) do |io|
io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
io.close_write unless options[:write_stdin]
block.call(io) if block_given?
end

but we can avoid the JRuby bug in many situations by changing this to:

mode = options[:write_stdin] ? "r+" : "r" 
IO.popen(cmd, mode) do |io|
io.set_encoding("ASCII-8BIT") if io.respond_to?(:set_encoding)
block.call(io) if block_given?
end

i.e. not using "r+" mode when we don't need to - I think this code is equivalent.

As far as I can tell only GitAdapter.revisions needs the :write_stdin option, and we could eliminate that one usage by pushing all the revisions onto the command line instead.

I hope that makes sense.

Actions

Also available in: Atom PDF