auth0/auth0-java

SDK ClassCastException during downtime

p0d3x opened this issue · 1 comments

p0d3x commented

Hello, I wanted to report this as a bug, but it doesn't let me. So it's a feature request now.

This code:
https://github.com/auth0/auth0-java/blob/master/src/main/java/com/auth0/exception/APIException.java#L159

caused:

java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String (java.lang.Integer and java.lang.String are in module java.base of loader 'bootstrap')
	at com.auth0.exception.APIException.obtainExceptionError(APIException.java:159)
	at com.auth0.exception.APIException.<init>(APIException.java:36)
	at com.auth0.net.ExtendedBaseRequest.createResponseException(ExtendedBaseRequest.java:131)
	at com.auth0.net.ExtendedBaseRequest.parseResponse(ExtendedBaseRequest.java:66)
	at com.auth0.net.BaseRequest.execute(BaseRequest.java:35)

When the Auth0 API was down/not available on March 5th between 02:46 and 02:47 UTC.

Ideally this should not cause an unhandled exception in this case.

Hi @p0d3x, thanks for raising this. It looks like when we create an APIException, we parse the response body into a map of <String, Object>, but then when creating the message or error we cast to a string. Perhaps we can instead call toString() when constructing the message/error; will need to investigate further.