< prev index next >

application/org.openjdk.jmc.rjmx.services.jfr/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java

Print this page

        

@@ -91,10 +91,11 @@
         private Map<EventTypeIDV2, EventTypeMetadataV2> eventTypeInfoById;
         private Map<org.openjdk.jmc.flightrecorder.configuration.events.EventOptionID, OptionInfo<?>> optionInfoById;
         private final ICommercialFeaturesService cfs;
         private final IMBeanHelperService mbhs;
         private final String serverId;
+        private final IConnectionHandle connection;
 
         @Override
         public String getVersion() {
                 return "2.0"; //$NON-NLS-1$
         }

@@ -102,15 +103,20 @@
         private boolean isDynamicFlightRecorderSupported(IConnectionHandle handle) {
                 return ConnectionToolkit.isHotSpot(handle)
                                 && ConnectionToolkit.isJavaVersionAboveOrEqual(handle, JavaVersionSupport.DYNAMIC_JFR_SUPPORTED);
         }
 
+        private boolean isFlightRecorderCommercial() {
+                return ConnectionToolkit.isHotSpot(connection)
+                                && !ConnectionToolkit.isJavaVersionAboveOrEqual(connection, JavaVersionSupport.JFR_NOT_COMMERCIAL);
+        }
+
         private boolean isFlightRecorderDisabled(IConnectionHandle handle) {
-                if (cfs != null) {
+                if (cfs != null && isFlightRecorderCommercial()) {
                         return !cfs.isCommercialFeaturesEnabled() || JVMSupportToolkit.isFlightRecorderDisabled(handle, false);
                 } else {
-                        return true;
+                        return JVMSupportToolkit.isFlightRecorderDisabled(handle, false);
                 }
         }
 
         public static boolean isAvailable(IConnectionHandle handle) {
                 return FlightRecorderCommunicationHelperV2.isAvailable(handle);

@@ -122,10 +128,11 @@
                         throw new ServiceNotAvailableException(""); //$NON-NLS-1$
                 }
                 if (JVMSupportToolkit.isFlightRecorderDisabled(handle, true)) {
                         throw new ServiceNotAvailableException(""); //$NON-NLS-1$
                 }
+                connection = handle;
                 helper = new FlightRecorderCommunicationHelperV2(handle.getServiceOrThrow(MBeanServerConnection.class));
                 mbhs = handle.getServiceOrThrow(IMBeanHelperService.class);
                 serverId = handle.getServerDescriptor().getGUID();
         }
 

@@ -468,11 +475,13 @@
                 return openStream(descriptor, startDate, endDate, removeOnClose);
         }
 
         @Override
         public boolean isEnabled() {
-                return cfs.isCommercialFeaturesEnabled();
+                return isFlightRecorderCommercial()
+                                ? cfs.isCommercialFeaturesEnabled()
+                                : isAvailable(connection);
         }
 
         @Override
         public void enable() throws FlightRecorderException {
                 try {
< prev index next >