You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2023/01/06 08:28:57 UTC

[GitHub] [skywalking-java] jinrongzhang commented on a diff in pull request #437: Put `Agent-Version` property reading in premain stage to avoid deadlock when use `jarsigner`.

jinrongzhang commented on code in PR #437:
URL: https://github.com/apache/skywalking-java/pull/437#discussion_r1063232810


##########
apm-sniffer/apm-agent-core/src/main/java/org/apache/skywalking/apm/agent/core/conf/SnifferConfigInitializer.java:
##########
@@ -202,6 +206,37 @@ private static void overrideConfigBySystemProp() {
         }
     }
 
+    /**
+     * set agent version(Described in MANIFEST.MF)
+     *
+     * */
+    private static void setAgentVersion() {
+        try {
+            ClassLoader classLoader = SnifferConfigInitializer.class.getClassLoader();
+            Enumeration<URL> resources = SnifferConfigInitializer.class.getClassLoader().getResources(JarFile.MANIFEST_NAME);
+            while (resources.hasMoreElements()) {
+                URL url = resources.nextElement();
+                LOGGER.info("SnifferConfigInitializer url:{}", url.toString());
+                try (InputStream is = url.openStream()) {
+                    if (is != null) {
+                        Manifest manifest = new Manifest(is);
+                        Attributes mainAttribs = manifest.getMainAttributes();
+                        String projectName = mainAttribs.getValue("Implementation-Vendor-Id");
+                        if (projectName != null) {
+                            if ("org.apache.skywalking".equals(projectName)) {
+                                String version = mainAttribs.getValue("Implementation-Version");
+                                AGENT_SETTINGS.put("agent.version", version);
+                            }
+                        }
+                    }
+                }
+            }

Review Comment:
   yes, i will fix it!



-- 
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: notifications-unsubscribe@skywalking.apache.org

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