JavaFX URLConnection HTTP Response Codes

741 Views Asked by At

I am struggling bad time trying to make an AngularJS application to run properly into an embedded JavaFX Webkit browser.

During the initialization, this is pretty normal that the application server returns a HTTP 401 (unauthorized). The Ajax handler in the app will manage to redirect the the login page, and to reissue the failed request later.

Although an IOException is thrown from default implementation of HttpUrlConnection from JVM when a > 400 error is thrown, and doesn't return the response inputstream to the app.

I tried myself to enhance this HTTPUrlConnection by using getErrorStream() when this IOException happens, but was time to have this:

@Override
public synchronized InputStream getInputStream() throws IOException {
    try {
        return super.getInputStream();
    } catch (IOException e) {
        return super.getErrorStream();
    }
}

 WARNING: Unexpected error
 java.lang.NullPointerException
at com.sun.webpane.webkit.network.URLLoader.close(Unknown Source)
at com.sun.webpane.webkit.network.URLLoader.doRun(Unknown Source)
at com.sun.webpane.webkit.network.URLLoader.access$000(Unknown Source)
at com.sun.webpane.webkit.network.URLLoader$1.run(Unknown Source)
at com.sun.webpane.webkit.network.URLLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.webpane.webkit.network.URLLoader.run(Unknown Source)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:724)

And still no response codes getting to the app.

Any thoughts?

Thank you

0

There are 0 best solutions below