auth0/auth0-java

RateLimitException contains wrong reset/limit and remaining information

alexz75 opened this issue · 1 comments

In case RateLimitException thrown it contains only -1 values for limit, remaing and reset

Running applications using management api to get a big amout of the information from auth0. Getting RateLimitException as expected, but it not contains proper information.

No workaround, cannot retry the requests

I've found that the server returns response headers in lower case, but the client is expecting it in different form (BaseRequest):

private RateLimitException createRateLimitException(Auth0HttpResponse response) {
        // -1 as default value if the header could not be found.
        long limit = Long.parseLong(response.getHeader("X-RateLimit-Limit", "-1"));
        long remaining = Long.parseLong(response.getHeader("X-RateLimit-Remaining", "-1"));
        long reset = Long.parseLong(response.getHeader("X-RateLimit-Reset", "-1"));
        return new RateLimitException(limit, remaining, reset);
 }

#528 was released in 2.2.0, which should be available in maven central shortly.