Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
import uk.gov.pay.api.managed.RedisClientManager;

import javax.inject.Singleton;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.util.concurrent.Callable;

@Singleton
public class RedisRateLimiter {
private static final Logger LOGGER = LoggerFactory.getLogger(RedisRateLimiter.class);
private static final StringWriter stringWriter = new StringWriter();
private static final PrintWriter printWriter = new PrintWriter(stringWriter);
private final MetricRegistry metricsRegistry;

private RateLimitManager rateLimitManager;
Expand All @@ -42,7 +46,11 @@ void checkRateOf(String accountId, RateLimiterKey key)
int rateLimitInterval = rateLimitManager.getRateLimitInterval(accountId);
count = updateAllowance(key.getKey(), rateLimitInterval);
} catch (Exception e) {
LOGGER.info("Failed to update allowance. Cause of error: " + e.getMessage());
LOGGER.info(String.format("Failed to update allowance. Cause of error: %s", e));
e.printStackTrace(printWriter);
LOGGER.info(stringWriter.toString());
stringWriter.flush();

// Exception possible if redis is unavailable or perMillis is too high
throw new RedisException();
}
Expand Down