[spotbugs] parse time using thread-safe DateTimeFormatter
LfsConnectionFactory used a static SimpleDateFormat which isn't thread-safe. Use DateTimeFormatter instead to fix this. Change-Id: Id580251c999e1e412c269f37b29860d310124c89 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
5b16f32de0
commit
f29668f7a0
|
@ -18,7 +18,9 @@
|
||||||
import java.net.ProxySelector;
|
import java.net.ProxySelector;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
@ -258,8 +260,8 @@ public static Protocol.Request toRequest(String operation,
|
||||||
private static final class AuthCache {
|
private static final class AuthCache {
|
||||||
private static final long AUTH_CACHE_EAGER_TIMEOUT = 500;
|
private static final long AUTH_CACHE_EAGER_TIMEOUT = 500;
|
||||||
|
|
||||||
private static final SimpleDateFormat ISO_FORMAT = new SimpleDateFormat(
|
private static final DateTimeFormatter ISO_FORMAT = DateTimeFormatter
|
||||||
"yyyy-MM-dd'T'HH:mm:ss.SSSX"); //$NON-NLS-1$
|
.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX"); //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a cache entry for an authentication response.
|
* Creates a cache entry for an authentication response.
|
||||||
|
@ -278,8 +280,10 @@ public AuthCache(Protocol.ExpiringAction action) {
|
||||||
- AUTH_CACHE_EAGER_TIMEOUT;
|
- AUTH_CACHE_EAGER_TIMEOUT;
|
||||||
} else if (action.expiresAt != null
|
} else if (action.expiresAt != null
|
||||||
&& !action.expiresAt.isEmpty()) {
|
&& !action.expiresAt.isEmpty()) {
|
||||||
this.validUntil = ISO_FORMAT.parse(action.expiresAt)
|
this.validUntil = LocalDateTime
|
||||||
.getTime() - AUTH_CACHE_EAGER_TIMEOUT;
|
.parse(action.expiresAt, ISO_FORMAT)
|
||||||
|
.atZone(ZoneOffset.UTC).toInstant().toEpochMilli()
|
||||||
|
- AUTH_CACHE_EAGER_TIMEOUT;
|
||||||
} else {
|
} else {
|
||||||
this.validUntil = System.currentTimeMillis();
|
this.validUntil = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue