Skip to content

Commit 28b3dee

Browse files
author
Jad Naous
committed
Correct time decoding in RetryAfterDecoder
currentTimeNanos was not returning nanos.
1 parent c678daa commit 28b3dee

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

‎core/src/main/java/feign/codec/ErrorDecoder.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static class RetryAfterDecoder {
113113
this.rfc822Format = checkNotNull(rfc822Format, "rfc822Format");
114114
}
115115

116-
protected long currentTimeNanos() {
116+
protected long currentTimeMillis() {
117117
return System.currentTimeMillis();
118118
}
119119

@@ -128,9 +128,8 @@ public Date apply(String retryAfter) {
128128
return null;
129129
}
130130
if (retryAfter.matches("^[0-9]+$")) {
131-
long currentTimeMillis = NANOSECONDS.toMillis(currentTimeNanos());
132131
long deltaMillis = SECONDS.toMillis(Long.parseLong(retryAfter));
133-
return new Date(currentTimeMillis + deltaMillis);
132+
return new Date(currentTimeMillis() + deltaMillis);
134133
}
135134
synchronized (rfc822Format) {
136135
try {

‎core/src/test/java/feign/codec/RetryAfterDecoderTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
public class RetryAfterDecoderTest {
3030

3131
private RetryAfterDecoder decoder = new RetryAfterDecoder(RFC822_FORMAT) {
32-
protected long currentTimeNanos() {
32+
protected long currentTimeMillis() {
3333
try {
34-
return MILLISECONDS.toNanos(RFC822_FORMAT.parse("Sat, 1 Jan 2000 00:00:00 GMT").getTime());
34+
return RFC822_FORMAT.parse("Sat, 1 Jan 2000 00:00:00 GMT").getTime();
3535
} catch (ParseException e) {
3636
throw new RuntimeException(e);
3737
}

0 commit comments

Comments
 (0)