Announcement Announcement Module
Collapse
No announcement yet.
CommandLineJobRunner and standard input Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CommandLineJobRunner and standard input

    I've noticed a problem with the org.springframework.batch.core.launch.support.Comm andLineJobRunner when using an environment without stdin available. In my case, launching an AutoSys job to run the CommandLineJobRunner, and standard input is not available. The code in question in the main method:
    Code:
    if (System.in.available() > 0) {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      String line = " ";
      while (StringUtils.hasLength(line)) {
        if (!line.startsWith("#") && StringUtils.hasText(line)) {
          logger.debug("Stdin arg: "+line);
          newargs.add(line);
        }
        line = reader.readLine();
      }
    }
    Line 517 (the first line quoted) throws an exception instead of gracefully continuing if standard input is not available:

    Code:
    Exception in thread "main" Exception in thread "main" java.io.IOException: Incorrect function
    	at java.io.FileInputStream.available(Native Method)
    	at java.io.BufferedInputStream.available(BufferedInputStream.java:381)
    	at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:517)
    Since I'm not using standard input to pass in parameters but using the command line instead, I had to comment out this section in order for the CommandLineJobRunner to execute properly. The code should be modified to properly handle the exception for this scenario. Thanks.

  • #2
    This looks like a bug, so you could raise a ticket in JIRA and post the link here so other people can find it later.

    Comment

    Working...
    X