mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8245306: Update sun.security.ssl.SSLLogger to use Immutable DateTimeFormatter
The fix updates sun.security.ssl.SSLLogger to use DateTimeFormatter to make it virtual thread friendly Reviewed-by: alanb, jnimeh
This commit is contained in:
parent
8b005fa74e
commit
778d8a45cb
2 changed files with 124 additions and 16 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -36,11 +36,13 @@ import java.security.cert.Certificate;
|
|||
import java.security.cert.Extension;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.text.MessageFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
import sun.security.x509.*;
|
||||
|
@ -254,13 +256,9 @@ public final class SSLLogger {
|
|||
}
|
||||
|
||||
private static class SSLSimpleFormatter {
|
||||
private static final ThreadLocal<SimpleDateFormat> dateFormat =
|
||||
new ThreadLocal<SimpleDateFormat>() {
|
||||
@Override protected SimpleDateFormat initialValue() {
|
||||
return new SimpleDateFormat(
|
||||
"yyyy-MM-dd kk:mm:ss.SSS z", Locale.ENGLISH);
|
||||
}
|
||||
};
|
||||
private static final String PATTERN = "yyyy-MM-dd kk:mm:ss.SSS z";
|
||||
private static final DateTimeFormatter dateTimeFormat = DateTimeFormatter.ofPattern(PATTERN, Locale.ENGLISH)
|
||||
.withZone(ZoneId.systemDefault());
|
||||
|
||||
private static final MessageFormat basicCertFormat = new MessageFormat(
|
||||
"\"version\" : \"v{0}\",\n" +
|
||||
|
@ -357,7 +355,7 @@ public final class SSLLogger {
|
|||
level.getName(),
|
||||
Utilities.toHexString(Thread.currentThread().getId()),
|
||||
Thread.currentThread().getName(),
|
||||
dateFormat.get().format(new Date(System.currentTimeMillis())),
|
||||
dateTimeFormat.format(Instant.now()),
|
||||
formatCaller(),
|
||||
message
|
||||
};
|
||||
|
@ -374,7 +372,7 @@ public final class SSLLogger {
|
|||
level.getName(),
|
||||
Utilities.toHexString(Thread.currentThread().getId()),
|
||||
Thread.currentThread().getName(),
|
||||
dateFormat.get().format(new Date(System.currentTimeMillis())),
|
||||
dateTimeFormat.format(Instant.now()),
|
||||
formatCaller(),
|
||||
message,
|
||||
(logger.useCompactFormat ?
|
||||
|
@ -476,8 +474,8 @@ public final class SSLLogger {
|
|||
x509.getSerialNumber().toByteArray()),
|
||||
x509.getSigAlgName(),
|
||||
x509.getIssuerX500Principal().toString(),
|
||||
dateFormat.get().format(x509.getNotBefore()),
|
||||
dateFormat.get().format(x509.getNotAfter()),
|
||||
dateTimeFormat.format(x509.getNotBefore().toInstant()),
|
||||
dateTimeFormat.format(x509.getNotAfter().toInstant()),
|
||||
x509.getSubjectX500Principal().toString(),
|
||||
x509.getPublicKey().getAlgorithm()
|
||||
};
|
||||
|
@ -501,8 +499,8 @@ public final class SSLLogger {
|
|||
x509.getSerialNumber().toByteArray()),
|
||||
x509.getSigAlgName(),
|
||||
x509.getIssuerX500Principal().toString(),
|
||||
dateFormat.get().format(x509.getNotBefore()),
|
||||
dateFormat.get().format(x509.getNotAfter()),
|
||||
dateTimeFormat.format(x509.getNotBefore().toInstant()),
|
||||
dateTimeFormat.format(x509.getNotAfter().toInstant()),
|
||||
x509.getSubjectX500Principal().toString(),
|
||||
x509.getPublicKey().getAlgorithm(),
|
||||
Utilities.indent(extBuilder.toString())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue