try catch - Java HttpURLConnection dying mysteriously -


i trying use java.net.httpurlconnection make simple http call , running can't explain:

public string makegetcall(httpurlconnection con) {     try {         system.out.println("about make request...");          if(con == null)             system.out.println("con null");         else {             system.out.println("con not null");              if(con.getinputstream() == null)                 system.out.println("con's input stream null");             else                 system.out.println("con's input stream not null");         }     } catch(throwable t) {         system.out.println("error: " + t.getmessage());     }      system.out.println("returning...")     return "dummy data"; } 

when run this, following console output:

about make request... con not null 

and program terminates, without error. no exceptions thrown, doesn't exit unexpectedly, , doesn't hang or timeout...it dies.

it seems dying when check con.getinputstream() being null or not. still doesn't explain why dies quietly without indication of error. ideas? i''m willing admit have created httpurlconnection incorrectly, still, there should more indication of killing program...thanks in advance!

it seems dying when check con.getinputstream() being null or not.

well find hard believe.

on face of it:

  • testing reference see if null cannot terminate program

  • the con.getinputstream() can either throw exception or return

  • if return shouldn't return null ... 'cos api doesn't allow ... , see message

  • if exception thrown see error: ... message

my conclusion either different thread causing application exit, or application not exiting @ all.

the other explanation can think of edit / compile / deploy / run procedure not working, , code being run doesn't match code showing use.

i suggest attempt create sscce other people can reproduce , figure out happening.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -