-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8051959: Add thread and timestamp options to java.security.debug system property #18084
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
Conversation
|
👋 Welcome back coffeys! A progress list of the required criteria for merging this PR into |
Webrevs
|
| String retString = ""; | ||
| if (printThreadDetails) { | ||
| retString = toHexString(Thread.currentThread().threadId()) + "|" + | ||
| Thread.currentThread().getName() + "|" + formatCaller(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thread ID is in decimal in the default string representation of thread, also other diagnostic features such as the new thread dump. So I think you want to change this to "#" + Thread.currentThread().threadId().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Alan. Today, the TLS javax.net.debug logging prints the thread ID in hex format. I was repeating behaviour seen from that impl. Having java.security.debug output in decimal and the other in hex would prove confusing. We could consider flipping both to decimal format in a follow on patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change it here, or in a later PR is okay. Main thing is that the logs are confusing then the Thread string is "#" but the TLS debug logs are different.
|
|
||
| } | ||
|
|
||
| // copied from sun/security/ssl/Utilities.java for now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why own helper, string.format(%x) can build the whole string or call Long.toHexString() or toString(,16)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was emulating what's done for the TLS logging code. Yes - I'll look at using a JDK library method instead.
|
|
||
| public void println() | ||
| { | ||
| System.err.println(prefix + ":"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we are her we could switch to Platfom logger, that also removes the need for timestamps (and thread info)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking along the same lines. the javax.net.debug property (TLS) already allows the use of System Logger. I'd be interested to hear from anyone who uses that Logger, by passing no args to javax.net.debug. No reason why this (java.security.debug) code couldn't be updated also. I'd like to do this in a follow on (hoping to backport this patch to LTS update releases)
I think the Logger experience could do with tweaking also - something I spoke briefly about at the recent OpenJDK Committers' Workshop in Brussels. One option might be a mechanism where the Logger Level can be dialed up and down remotely (e.g. jconsole). I've been looking at this with the PlatformLoggingMXBean.setLoggerLevel operation.
seanjmullan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some initial comments.
| System.err.println("+timestamp can be appended to any of above options to print"); | ||
| System.err.println(" a timestamp for that debug option"); | ||
| System.err.println("+thread can be appended to any of above options to print"); | ||
| System.err.println(" thread information for that debug option"); | ||
| System.err.println(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more reasonable to place these lines after line 113 ("x509") which are the main options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes - can do.
| args = marshal(args); | ||
| if (args.equals("help")) { | ||
| Help(); | ||
| } else if (args.contains("all")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest adding a comment explaining why you need to treat all specially here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good point - will update in next commit
| d.printThreadDetails = getConfigInfo(option, "+thread"); | ||
| d.printDateTime = getConfigInfo(option, "+timestamp"); | ||
| if (d.printDateTime && !dateTimeFormatInitialized) { | ||
| // trigger loading of Locale service impl now to avoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may want to try the test case added in JDK-8280890 with debugging enabled to make sure you don't get a similar recursion issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting - I did add -Djava,security.debug=all to the internals of that test and see issues.
However - they're issues that exist even without my patch. I need to take a closer look. sun.util.locale.provider.LocaleServiceProviderPool doesn't like to be invoked too early. That's a concern - maybe it should be able to handle such scenarios and return a simple/default Locale provider.
Caused by: java.lang.IllegalStateException: getSystemClassLoader cannot be called during the system class loader instantiation
at java.lang.ClassLoader.getSystemClassLoader([java.base@23-ea](mailto:java.base@23-ea)/ClassLoader.java:1952)
at java.lang.ClassLoader.getSystemResources([java.base@23-ea](mailto:java.base@23-ea)/ClassLoader.java:1723)
at java.util.ServiceLoader$LazyClassPathLookupIterator.nextProviderClass([java.base@23-ea](mailto:java.base@23-ea)/ServiceLoader.java:1189)
at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService([java.base@23-ea](mailto:java.base@23-ea)/ServiceLoader.java:1224)
at java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext([java.base@23-ea](mailto:java.base@23-ea)/ServiceLoader.java:1269)
at java.util.ServiceLoader$2.hasNext([java.base@23-ea](mailto:java.base@23-ea)/ServiceLoader.java:1305)
at java.util.ServiceLoader$3.hasNext([java.base@23-ea](mailto:java.base@23-ea)/ServiceLoader.java:1387)
at sun.util.cldr.CLDRLocaleProviderAdapter.lambda$new$0([java.base@23-ea](mailto:java.base@23-ea)/CLDRLocaleProviderAdapter.java:84)
at java.security.AccessController.doPrivileged([java.base@23-ea](mailto:java.base@23-ea)/AccessController.java:571)
at sun.util.cldr.CLDRLocaleProviderAdapter.<init>([java.base@23-ea](mailto:java.base@23-ea)/CLDRLocaleProviderAdapter.java:83)
at jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance([java.base@23-ea](mailto:java.base@23-ea)/DirectConstructorHandleAccessor.java:62)
at java.lang.reflect.Constructor.newInstanceWithCaller([java.base@23-ea](mailto:java.base@23-ea)/Constructor.java:502)
at java.lang.reflect.Constructor.newInstance([java.base@23-ea](mailto:java.base@23-ea)/Constructor.java:486)
at sun.util.locale.provider.LocaleProviderAdapter.forType([java.base@23-ea](mailto:java.base@23-ea)/LocaleProviderAdapter.java:182)
at sun.util.locale.provider.LocaleServiceProviderPool.findProviders([java.base@23-ea](mailto:java.base@23-ea)/LocaleServiceProviderPool.java:311)
at sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObjectImpl([java.base@23-ea](mailto:java.base@23-ea)/LocaleServiceProviderPool.java:283)
at sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObject([java.base@23-ea](mailto:java.base@23-ea)/LocaleServiceProviderPool.java:245)
at sun.util.locale.provider.TimeZoneNameUtility.retrieveDisplayNamesImpl([java.base@23-ea](mailto:java.base@23-ea)/TimeZoneNameUtility.java:197)
at sun.util.locale.provider.TimeZoneNameUtility.retrieveDisplayName([java.base@23-ea](mailto:java.base@23-ea)/TimeZoneNameUtility.java:150)
at java.util.TimeZone.getDisplayName([java.base@23-ea](mailto:java.base@23-ea)/TimeZone.java:430)
at java.util.Date.toString([java.base@23-ea](mailto:java.base@23-ea)/Date.java:1045)
at java.lang.String.valueOf([java.base@23-ea](mailto:java.base@23-ea)/String.java:4509)
at java.lang.StringBuilder.append([java.base@23-ea](mailto:java.base@23-ea)/StringBuilder.java:173)
at sun.security.x509.CertificateValidity.toString([java.base@23-ea](mailto:java.base@23-ea)/CertificateValidity.java:118)
at java.lang.String.valueOf([java.base@23-ea](mailto:java.base@23-ea)/String.java:4509)
at java.lang.StringBuilder.append([java.base@23-ea](mailto:java.base@23-ea)/StringBuilder.java:173)
at sun.security.x509.X509CertInfo.toString([java.base@23-ea](mailto:java.base@23-ea)/X509CertInfo.java:221)
at java.lang.String.valueOf([java.base@23-ea](mailto:java.base@23-ea)/String.java:4509)
at java.lang.StringBuilder.append([java.base@23-ea](mailto:java.base@23-ea)/StringBuilder.java:173)
at sun.security.x509.X509CertImpl.toString([java.base@23-ea](mailto:java.base@23-ea)/X509CertImpl.java:560)
at java.lang.String.valueOf([java.base@23-ea](mailto:java.base@23-ea)/String.java:4509)
at java.lang.StringBuilder.append([java.base@23-ea](mailto:java.base@23-ea)/StringBuilder.java:173)
at sun.security.util.SignatureFileVerifier.getSigners([java.base@23-ea](mailto:java.base@23-ea)/SignatureFileVerifier.java:742)
at sun.security.util.SignatureFileVerifier.processImpl([java.base@23-ea](mailto:java.base@23-ea)/SignatureFileVerifier.java:312)
at sun.security.util.SignatureFileVerifier.process([java.base@23-ea](mailto:java.base@23-ea)/SignatureFileVerifier.java:281)
at java.util.jar.JarVerifier.processEntry([java.base@23-ea](mailto:java.base@23-ea)/JarVerifier.java:320)
at java.util.jar.JarVerifier.update([java.base@23-ea](mailto:java.base@23-ea)/JarVerifier.java:232)
at java.util.jar.JarFile.initializeVerifier([java.base@23-ea](mailto:java.base@23-ea)/JarFile.java:760)
at java.util.jar.JarFile.getInputStream([java.base@23-ea](mailto:java.base@23-ea)/JarFile.java:858)
at jdk.internal.loader.URLClassPath$JarLoader$2.getInputStream([java.base@23-ea](mailto:java.base@23-ea)/URLClassPath.java:837)
at jdk.internal.loader.Resource.cachedInputStream([java.base@23-ea](mailto:java.base@23-ea)/Resource.java:77)
at jdk.internal.loader.Resource.getByteBuffer([java.base@23-ea](mailto:java.base@23-ea)/Resource.java:163)
at jdk.internal.loader.BuiltinClassLoader.defineClass([java.base@23-ea](mailto:java.base@23-ea)/BuiltinClassLoader.java:853)
at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull([java.base@23-ea](mailto:java.base@23-ea)/BuiltinClassLoader.java:760)
at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull([java.base@23-ea](mailto:java.base@23-ea)/BuiltinClassLoader.java:681)
at jdk.internal.loader.BuiltinClassLoader.loadClass([java.base@23-ea](mailto:java.base@23-ea)/BuiltinClassLoader.java:639)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass([java.base@23-ea](mailto:java.base@23-ea)/ClassLoaders.java:188)
at java.lang.ClassLoader.loadClass([java.base@23-ea](mailto:java.base@23-ea)/ClassLoader.java:528)
at java.lang.Class.forName0([java.base@23-ea](mailto:java.base@23-ea)/Native Method)
at java.lang.Class.forName([java.base@23-ea](mailto:java.base@23-ea)/Class.java:578)
at java.lang.Class.forName([java.base@23-ea](mailto:java.base@23-ea)/Class.java:557)
at java.lang.ClassLoader.initSystemClassLoader([java.base@23-ea](mailto:java.base@23-ea)/ClassLoader.java:1997)
at java.lang.System.initPhase3([java.base@23-ea](mailto:java.base@23-ea)/System.java:2338)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. It seems any attempt to calls like Date.toString() early on that triggers a TimeZone lookup is going to potentially cause this. A possible workaround is to change CertificateValidity.toString() to emit dates as Date.toInstant().toString() which is similar to what I did in the fix for JDK-8280890. But this is a separate issue.
|
@coffeys This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 141 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
| retString = toHexString(Thread.currentThread().threadId()) + "|" + | ||
| Thread.currentThread().getName() + "|" + formatCaller(); | ||
| retString = "0x" + Long.toHexString( | ||
| Thread.currentThread().threadId()).toUpperCase(Locale.ROOT) + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmhh.. i can understand the desire to unify casing, but maybe changing the other logs to use javas default casing for hex (instead of changing it here) makes the code faster and better to read?
(Not sure if StringBuilder optimization (including starting with [) would be worth the complication)
|
Suggest changing the title of the issue to "Add thread and timestamp options to java.security.debug system property" |
| System.err.println("+timestamp can be appended to any of above options to print"); | ||
| System.err.println(" a timestamp for that debug option"); | ||
| System.err.println("+thread can be appended to any of above options to print"); | ||
| System.err.println(" thread information for that debug option"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about mentioning caller too? "thread and caller information ..."
| threadInfoAll = args.substring(beginIndex, commaIndex).contains("+thread");; | ||
| timeStampInfoAll = args.substring(beginIndex, commaIndex).contains("+timestamp");; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra semi-colon at end of line.
|
@wangweij |
| printDateTime = getConfigInfo(option, "+timestamp", ofInstance); | ||
| if (printDateTime && !dateTimeFormatInitialized) { | ||
| // trigger loading of Locale service impl now to avoid | ||
| // possible bootstrap recursive class load issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be manually loaded? I thought the FormatHolder field will be automatically loaded when it's first accessed and only once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still necessary I'm afraid. During an early classloader operation, the Security class can be triggered which causes security properties to be read. If debugging is enabled, this triggers loading of CLDR service. Quite a long stack trace but I'll paste it here for history.
I agree on your other comments - I'll try a clean up and will come back to you then.
stderr: [Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.util.ServiceConfigurationError: Locale provider adapter "CLDR"cannot be instantiated.
at java.base/sun.util.locale.provider.LocaleProviderAdapter.forType(LocaleProviderAdapter.java:193)
at java.base/sun.util.locale.provider.LocaleServiceProviderPool.findProviders(LocaleServiceProviderPool.java:311)
at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObjectImpl(LocaleServiceProviderPool.java:283)
at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObject(LocaleServiceProviderPool.java:245)
at java.base/sun.util.locale.provider.TimeZoneNameUtility.retrieveDisplayNamesImpl(TimeZoneNameUtility.java:197)
at java.base/sun.util.locale.provider.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:120)
at java.base/java.time.format.DateTimeFormatterBuilder$ZoneTextPrinterParser.getDisplayName(DateTimeFormatterBuilder.java:4484)
at java.base/java.time.format.DateTimeFormatterBuilder$ZoneTextPrinterParser.format(DateTimeFormatterBuilder.java:4535)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2537)
at java.base/java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1905)
at java.base/java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1879)
at java.base/sun.security.util.Debug.extraInfo(Debug.java:345)
at java.base/sun.security.util.Debug.println(Debug.java:299)
at java.base/java.security.Security.loadProps(Security.java:161)
at java.base/java.security.Security.initialize(Security.java:103)
at java.base/java.security.Security.lambda$static$0(Security.java:84)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:319)
at java.base/java.security.Security.<clinit>(Security.java:83)
at java.base/sun.security.util.SecurityProperties.getOverridableProperty(SecurityProperties.java:57)
at java.base/sun.security.util.SecurityProperties.privilegedGetOverridable(SecurityProperties.java:48)
at java.base/sun.security.util.SecurityProperties.includedInExceptions(SecurityProperties.java:72)
at java.base/sun.security.util.SecurityProperties.<clinit>(SecurityProperties.java:36)
at java.base/sun.security.util.FilePermCompat.<clinit>(FilePermCompat.java:43)
at java.base/java.io.FilePermission.init(FilePermission.java:319)
at java.base/java.io.FilePermission.<init>(FilePermission.java:490)
at java.base/sun.net.www.protocol.file.FileURLConnection.getPermission(FileURLConnection.java:223)
at java.base/sun.security.util.LazyCodeSourcePermissionCollection.ensureAdded(LazyCodeSourcePermissionCollection.java:69)
at java.base/sun.security.util.LazyCodeSourcePermissionCollection.toString(LazyCodeSourcePermissionCollection.java:115)
at java.base/java.lang.String.valueOf(String.java:4509)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
at java.base/java.security.ProtectionDomain.toString(ProtectionDomain.java:434)
at java.base/java.lang.String.valueOf(String.java:4509)
at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
at java.base/java.security.SecureClassLoader$1.apply(SecureClassLoader.java:231)
at java.base/java.security.SecureClassLoader$1.apply(SecureClassLoader.java:222)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1713)
at java.base/java.security.SecureClassLoader.getProtectionDomain(SecureClassLoader.java:222)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:528)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:578)
at java.base/java.lang.Class.forName(Class.java:557)
at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:847)
at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:732)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at java.base/sun.util.locale.provider.LocaleProviderAdapter.forType(LocaleProviderAdapter.java:182)
... 48 more
Caused by: java.util.ServiceConfigurationError: Locale provider adapter "CLDR"cannot be instantiated.
at java.base/sun.util.locale.provider.LocaleProviderAdapter.forType(LocaleProviderAdapter.java:193)
at java.base/sun.util.locale.provider.LocaleServiceProviderPool.findProviders(LocaleServiceProviderPool.java:311)
at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObjectImpl(LocaleServiceProviderPool.java:283)
at java.base/sun.util.locale.provider.LocaleServiceProviderPool.getLocalizedObject(LocaleServiceProviderPool.java:245)
at java.base/sun.util.locale.provider.TimeZoneNameUtility.retrieveDisplayNamesImpl(TimeZoneNameUtility.java:197)
at java.base/sun.util.locale.provider.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:120)
at java.base/java.time.format.DateTimeFormatterBuilder$ZoneTextPrinterParser.getDisplayName(DateTimeFormatterBuilder.java:4484)
at java.base/java.time.format.DateTimeFormatterBuilder$ZoneTextPrinterParser.format(DateTimeFormatterBuilder.java:4535)
at java.base/java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2537)
at java.base/java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1905)
at java.base/java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1879)
at java.base/sun.security.util.Debug.extraInfo(Debug.java:345)
at java.base/sun.security.util.Debug.println(Debug.java:299)
at java.base/java.security.SecureClassLoader$1.apply(SecureClassLoader.java:231)
at java.base/java.security.SecureClassLoader$1.apply(SecureClassLoader.java:222)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1713)
at java.base/java.security.SecureClassLoader.getProtectionDomain(SecureClassLoader.java:222)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:182)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:741)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClass(BuiltinClassLoader.java:621)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:640)
at java.base/java.lang.Class.forName(Class.java:669)
at java.base/java.lang.Class.forName(Class.java:644)
at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:855)
at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.hasNext(ServiceLoader.java:1080)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1391)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter.lambda$new$0(CLDRLocaleProviderAdapter.java:84)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter.<init>(CLDRLocaleProviderAdapter.java:83)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
... 51 more
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
at java.base/sun.util.locale.provider.LocaleProviderAdapter.forType(LocaleProviderAdapter.java:182)
... 82 more
Caused by: java.lang.IllegalStateException: Recursive update
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1768)
at java.base/java.security.SecureClassLoader.getProtectionDomain(SecureClassLoader.java:222)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:182)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassInModuleOrNull(BuiltinClassLoader.java:741)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClass(BuiltinClassLoader.java:621)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:640)
at java.base/java.lang.Class.forName(Class.java:669)
at java.base/java.lang.Class.forName(Class.java:644)
at java.base/java.util.ServiceLoader.loadProvider(ServiceLoader.java:855)
at java.base/java.util.ServiceLoader$ModuleServicesLookupIterator.hasNext(ServiceLoader.java:1080)
at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1309)
at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1391)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter.lambda$new$0(CLDRLocaleProviderAdapter.java:84)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:571)
at java.base/sun.util.cldr.CLDRLocaleProviderAdapter.<init>(CLDRLocaleProviderAdapter.java:83)
at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
... 85 more
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that it's the java.time.format.DateTimeFormatterBuilder.ZoneTextPrinterParser#format call that triggers the early initialization of the CLDR service (via a getDisplayName call)
We can avoid this call if we print time data without timezone ID - i.e.
using a pattern of "yyyy-MM-dd kk:mm:ss.SSS" rather than "yyyy-MM-dd kk:mm:ss.SSS z"
example of change: (no UTC printed)
(with display name) :
properties[2024-03-22 09:55:48.985 UTC]: Initial security property: keystore.type.compat=true
(without):
properties[2024-03-22 09:55:48.985]: Initial security property: keystore.type.compat=true
I think we can live without the display name detail. Most logs relate to local timezone systems. It shortens the print also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, using local timezone is OK. Your new test adds a -Duser.timezone=UTC and I doubt anyone is likely to change that.
Back to my comment, I don't understand how this could fix the recursion. This check is also done very early and why doesn't that FormatHolder.DATE_TIME_FORMATTER.format(Instant.now()) trigger a similar error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, I just tried java -Djava.security.debug=all+timestamp sun.security.util.Debug and there is an error no matter the if block is there or not.
I'm running with an exploded build. Hopefully that makes no difference.
And, both case are fine if the Z is removed from PATTERN.
| } | ||
|
|
||
| // parse an option string to determine if extra details | ||
| // (like thread and timestamp) should be printed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this method (and maybe also configureOptions) a little confusing. The option argument is the option name for getInstance but the property value for of. You can see that in this method there is completely no shared code between ofInstance being true or false.
| * } | ||
| * @param option the debug option name | ||
| * @param prefix the debug option name | ||
| * @param property debug setting for this option |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some words on the format that propertycan take.
|
Updates pushed to incorporate review comments to date. As mentioned, the CLDR JNI issue is triggered via the display name lookup (e.g. "UTC") - we can edit the date string format to not include this data. I've removed the early lookup workaround code as a result. |
|
@wangweij found a scenario where the String parsing in the Method patched and test coverage updated |
|
/integrate |
|
Going to push as commit 3b582df.
Your commit was automatically rebased without conflicts. |
Proposal to improve the
java.security.debugoutput so that options exist to add thread ID, thread name, source of log record and a timestamp information to the output.examples:
format without patch :
format with thread info included:
format with thread info and timestamp:
It's a similar format to what can be seen when the TLS (javax.net.debug) debug logging option is in use
current proposal is to keep the thread and timestamp information off (make it opt in)
The extra decorator info is controlled by appending option to each component specified in the
"java.security.debug"option list.e.g
-Djava.security.debug=properties+timestamp+threadturns on logging for thepropertiescomponent and also decorates the records with timestamp and thread info-Djava.security.debug=properties+thread+timestamp,keystore would decorate the
propertiescomponent but no decorating performed for thekeystorecomponent.Progress
Issues
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18084/head:pull/18084$ git checkout pull/18084Update a local copy of the PR:
$ git checkout pull/18084$ git pull https://git.openjdk.org/jdk.git pull/18084/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18084View PR using the GUI difftool:
$ git pr show -t 18084Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18084.diff
Webrev
Link to Webrev Comment