openanalytics / containerproxy

Manage HTTP proxy routes into Docker containers
Apache License 2.0
43 stars 66 forks source link

Fix NPE in ErrorController #40

Closed johan13 closed 3 years ago

johan13 commented 4 years ago

I frequently get NullPointerExceptions when loading the index page. I believe this happens when my authentication has timed out. The bug appears to have been introduced by this commit.

I run a local build of the current develop branch + #39. Authentication is done with openid / Azure AD.

Error
Status code: 500

Message: An unexpected server error occurred

Stack Trace:
java.lang.NullPointerException
at eu.openanalytics.containerproxy.ui.ErrorController.isAccountStatusException(ErrorController.java:108)
at eu.openanalytics.containerproxy.ui.ErrorController.handleError(ErrorController.java:54)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209)
...
johan13 commented 4 years ago

I am not sure this was the right fix. Now I'm getting the "200 OK" errors instead.

Edit: I tried treating null as an AccountStatusException and that works better in my usecase, but I suppose the real solution is to make sure the exception is available in handleError, right?

LEDfan commented 3 years ago

Hi @johan13

Thanks for your contribution. We experienced similar errors on one of our deployments (when using Keycloak) and fixed this in the just released 2.5.0 release. Your changes were in the right direction, but as you mentioned some extra care was needed. (It was fixed in this commit, if you would be interested https://github.com/openanalytics/containerproxy/commit/15061f406970b183020a880a50bce3503bde90a3)

Since this is fixed now, I'm closing this issue. As always, feel free to open a new issue if you encounter any problem.