abhishekrb19 commented on code in PR #19123:
URL: https://github.com/apache/druid/pull/19123#discussion_r2978508360
##########
server/src/main/java/org/apache/druid/server/DruidNode.java:
##########
@@ -266,6 +275,33 @@ public String getVersion()
return version;
}
+ public String getBuildRevision()
+ {
+ return buildRevision;
+ }
+
+ /**
+ * Reads the {@code Build-Revision} attribute from the MANIFEST.MF of the
JAR containing this class.
+ * Returns null when running outside a packaged JAR (e.g., during {@code mvn
test}).
+ */
+ private static String readBuildRevisionFromManifest()
+ {
+ try {
+ URL classUrl =
DruidNode.class.getResource(DruidNode.class.getSimpleName() + ".class");
+ if (classUrl != null && "jar".equals(classUrl.getProtocol())) {
+ String classPath = classUrl.toString();
+ String manifestPath = classPath.substring(0,
classPath.lastIndexOf('!') + 1) + "/META-INF/MANIFEST.MF";
+ try (InputStream is = new URL(manifestPath).openStream()) {
+ return new
Manifest(is).getMainAttributes().getValue("Build-Revision");
+ }
+ }
+ }
+ catch (IOException e) {
+ // Fall through and return null
+ }
+ return null;
+ }
Review Comment:
We can create a class `BuildInfo` and move this utility to it so both
EmitterModule and the DruidNode code here can share it. We can also add more
build-related utilities to this class in the future.
--
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]