mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-05 13:05:44 +01:00
Formatter is not thread safe
This commit is contained in:
@@ -3,23 +3,26 @@ package sonia.scm.web.lfs;
|
||||
import org.eclipse.jgit.lfs.server.Response;
|
||||
import sonia.scm.security.AccessToken;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.TimeZone;
|
||||
|
||||
class ExpiringAction extends Response.Action {
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
static {
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
}
|
||||
|
||||
@SuppressWarnings({"squid:S00116"})
|
||||
// This class is used for json serialization, only
|
||||
public final String expires_at;
|
||||
|
||||
ExpiringAction(String href, AccessToken accessToken) {
|
||||
this.expires_at = DATE_FORMAT.format(accessToken.getExpiration());
|
||||
this.expires_at = createDateFormat().format(accessToken.getExpiration());
|
||||
this.href = href;
|
||||
this.header = Collections.singletonMap("Authorization", "Bearer " + accessToken.compact());
|
||||
}
|
||||
|
||||
private DateFormat createDateFormat() {
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
|
||||
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
return dateFormat;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user