Install SIGPIPE handler in the Avro tools main method.
------------------------------------------------------

                 Key: AVRO-697
                 URL: https://issues.apache.org/jira/browse/AVRO-697
             Project: Avro
          Issue Type: Improvement
          Components: java
            Reporter: Patrick Linehan


The following command should complete quickly, no matter how many records 
"myfile.avro" contains:

  java -jar avro-tools.jar tojson myfile.avro | head

However, because the tool JAR's main method does not install a SIGPIPE handler, 
this command can be quite slow for large files.

Suggested fix is to install a handler which calls "System.exit(128 + 
signal.getNumber())" in response to SIGPIPE.  Typically the signal number 
("getNumber") is 13, but no need to hard code it.

Potential issues:

* Tests which invoke Main.main() will necessarily force the signal handler to 
be installed.  This may be undesirable, as the entire test JVM will be 
"infected" with the handler.  Workarounds exist.  Does not bother me, 
personally, however.
* Installing signal handlers generates compile-time warnings, if I'm not 
mistaken.  Workarounds exist.  Does not bother me, personally, however.

If this suggestion sounds reasonable, I'll post a patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to