Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knox-3042 dummy #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 @@ -20,10 +20,15 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Locale;

public class KnoxToken implements Comparable<KnoxToken>{
public class KnoxToken implements Comparable<KnoxToken> {
private static final Comparator<KnoxToken> COMPARATOR = Comparator
.comparingLong((KnoxToken kt) -> kt.issueTime)
.thenComparing(kt -> kt.tokenId);

public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
// SimpleDateFormat is not thread safe must use as a ThreadLocal
private static final ThreadLocal<DateFormat> KNOX_TOKEN_TS_FORMAT = ThreadLocal
Expand Down Expand Up @@ -93,7 +98,7 @@ public boolean hasMetadata(String key) {

@Override
public int compareTo(KnoxToken other) {
return Long.compare(this.issueTime, other.issueTime);
return COMPARATOR.compare(this, other);
}

public void addMetadata(String name, String value) {
Expand Down
Loading