jackjlli commented on a change in pull request #7782:
URL: https://github.com/apache/pinot/pull/7782#discussion_r751790345



##########
File path: pinot-common/src/main/java/org/apache/pinot/common/Utils.java
##########
@@ -145,4 +149,36 @@ public static void logVersions() {
 
     return componentVersions;
   }
+
+  public static String getGitInfo() {
+    // unless Utils was somehow loaded on the bootclasspath, this will not be 
null
+    // and will find all manifests
+    ClassLoader classLoader = Utils.class.getClassLoader();
+    if (classLoader != null) {
+      try {
+        Enumeration<URL> manifests = 
classLoader.getResources("META-INF/MANIFEST.MF");
+        while (manifests.hasMoreElements()) {
+          URL url = manifests.nextElement();
+          try (InputStream stream = url.openStream()) {
+            Manifest manifest = new Manifest(stream);
+            Attributes attributes = manifest.getMainAttributes();
+            if (attributes != null) {
+              String implementationTitle = 
attributes.getValue(Attributes.Name.IMPLEMENTATION_TITLE);
+              if (implementationTitle != null && 
implementationTitle.contains("pinot")) {
+                String branch = attributes.getValue(IMPLEMENTATION_BRANCH);
+                String gitCommitId = 
attributes.getValue(IMPLEMENTATION_COMMIT);
+                if (!Strings.isNullOrEmpty(branch) && 
!Strings.isNullOrEmpty(gitCommitId)) {
+                  return branch + "/" + gitCommitId;
+                }
+              }
+            }
+          }
+        }
+      } catch (IOException e) {
+        // ignore

Review comment:
       Yeah I agree that the worst case is that commit hash won't be returned, 
but what I'm interested in here is to show any informative message for **pinot 
dev/ admin** to help debug the exception instead of silently swallowing it. 
We've already had the try catch blocks here, it'd be good to make use of it. 
   I'm fine with keeping it as is, just a good to have. 




-- 
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: commits-unsubscr...@pinot.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to