You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2021/11/24 20:04:04 UTC

[GitHub] [lucene] dweiss commented on a change in pull request #473: LUCENE-10260: Luke's about window no longer shows version number

dweiss commented on a change in pull request #473:
URL: https://github.com/apache/lucene/pull/473#discussion_r756389521



##########
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:
       NPE?




-- 
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: issues-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org