clintropolis commented on a change in pull request #8352: Handle exception 
thrown in log while trying to call sun.misc.VM.maxDirectMemory() which is not 
available in Java 11
URL: https://github.com/apache/incubator-druid/pull/8352#discussion_r316931572
 
 

 ##########
 File path: services/src/main/java/org/apache/druid/cli/GuiceRunnable.java
 ##########
 @@ -78,12 +78,20 @@ public Lifecycle initLifecycle(Injector injector)
       final Lifecycle lifecycle = injector.getInstance(Lifecycle.class);
       final StartupLoggingConfig startupLoggingConfig = 
injector.getInstance(StartupLoggingConfig.class);
 
+      Long directSizeBytes = null;
+      try {
+        directSizeBytes = JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes();
+      }
+      catch (UnsupportedOperationException ignore) {
+        // querying direct memory is not supported
+      }
+
       log.info(
-          "Starting up with processors[%,d], memory[%,d], maxMemory[%,d], 
directMemory[%,d].",
+          "Starting up with processors[%,d], memory[%,d], maxMemory[%,d]%s.",
           JvmUtils.getRuntimeInfo().getAvailableProcessors(),
           JvmUtils.getRuntimeInfo().getTotalHeapSizeBytes(),
           JvmUtils.getRuntimeInfo().getMaxHeapSizeBytes(),
-          JvmUtils.getRuntimeInfo().getDirectMemorySizeBytes()
+          directSizeBytes != null ? String.format(", directMemory[%,d]", 
directSizeBytes) : ""
 
 Review comment:
   Ah, this should use `StringUtils.format` instead of `String.format`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to