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:
Line 517 (the first line quoted) throws an exception instead of gracefully continuing if standard input is not available: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(); } }
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.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)


Reply With Quote
