Results 1 to 2 of 2

Thread: CommandLineJobRunner and standard input

Hybrid View

  1. #1
    Join Date
    Mar 2011
    Posts
    1

    Default 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. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •