Issue Type: Bug Bug
Affects Versions: current
Assignee: Unassigned
Components: cli
Created: 05/Jul/13 9:00 AM
Description:

When using Jenkins CLI, I get the following exception:

Exception in thread "main" java.lang.NullPointerException
    at hudson.cli.CLI.flushURLConnection(CLI.java:310)
    at hudson.cli.CLI.getCliTcpPort(CLI.java:285)
    at hudson.cli.CLI.<init>(CLI.java:134)
    at hudson.cli.CLIConnectionFactory.connect(CLIConnectionFactory.java:72)
    at hudson.cli.CLI._main(CLI.java:469)
    at hudson.cli.CLI.main(CLI.java:384)

The code where the exception is thrown looks like this:

299    private void flushURLConnection(URLConnection conn) {
300        byte[] buf = new byte[1024];
301        try {
302            InputStream is = conn.getInputStream();
303            while (is.read(buf) >= 0) {
304                // Ignore
305            }
306            is.close();
307        } catch (IOException e) {
308            try {
309                InputStream es = ((HttpURLConnection)conn).getErrorStream();
310                while (es.read(buf) >= 0) {
311                    // Ignore
312                }
313                es.close();
314            } catch (IOException ex) {
315                // Ignore
316            }
317        }
318    }

It seems that es is null, the documentation for getErrorStream states:


public InputStream getErrorStream()

Returns:
  an error stream if any, null if there have been no errors, the connection is not connected or the server sent no useful data.

A solution is just to add a check for null before reading from the stream. But maybe there is some deeper problem here because the NullPointerException occurs in a catch block of an IOException. But output from both the input stream and error stream is ignored so perhaps it is nothing to worry about?

The CLI is used from jobs in Jenkins, so this cause builds to fail. It is only on some nodes this is happening so the root cause is probably an environment issue because using the CLI has worked before.

Project: Jenkins
Labels: jenkins exception
Priority: Major Major
Reporter: Anders Engqvist
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to