dweiss commented on a change in pull request #473:
URL: https://github.com/apache/lucene/pull/473#discussion_r756389712
##########
File path: lucene/core/src/java/org/apache/lucene/LucenePackage.java
##########
@@ -16,13 +16,53 @@
*/
package org.apache.lucene;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.util.jar.Manifest;
+
/** Lucene's package information, including version. */
public final class LucenePackage {
+ private static LucenePackage lazyInstance;
+ private final String implementationVersion;
- private LucenePackage() {} // can't construct
+ private LucenePackage(String implementationVersion) {
+ this.implementationVersion = implementationVersion;
+ }
/** Return Lucene's package, including version information. */
- public static Package get() {
- return LucenePackage.class.getPackage();
+ public static synchronized LucenePackage get() {
+ if (lazyInstance == null) {
+ String version;
+
+ Package p = LucenePackage.class.getPackage();
+ version = p.getImplementationVersion();
+
+ if (version == null) {
+ var module = LucenePackage.class.getModule();
+ if (module.isNamed()) {
+ // Running as a module? Try parsing the manifest manually.
+ InputStream is = null;
+ try {
Review comment:
(if manifest is not there for some reason).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]