11/*******************************************************************************
2- * Copyright (c) 2019, 2020 Pivotal, Inc.
2+ * Copyright (c) 2019, 2024 Pivotal, Inc.
33 * All rights reserved. This program and the accompanying materials
44 * are made available under the terms of the Eclipse Public License v1.0
55 * which accompanies this distribution, and is available at
2929import javax .management .ObjectName ;
3030import javax .management .Query ;
3131import javax .management .QueryExp ;
32+ import javax .management .ReflectionException ;
3233import javax .management .remote .JMXConnector ;
3334
3435import org .json .JSONArray ;
@@ -604,8 +605,15 @@ private LiveRequestMapping[] parseRequestMappingsJson(String json, String bootVe
604605
605606 public LiveConditional [] getConditionals (MBeanServerConnection connection , String domain , String processId , String processName ) {
606607 try {
608+ //Boot 3.x
609+ Object result = getActuatorDataFromOperation (connection , getObjectName (domain , "type=Endpoint,name=Conditions" ), "conditions" );
610+ if (result != null ) {
611+ String report = gson .toJson (result );
612+ return LiveConditionalParser .parse (report , processId , processName );
613+ }
614+
607615 //Boot 2.x
608- Object result = getActuatorDataFromOperation (connection , getObjectName (domain , "type=Endpoint,name=Conditions" ), "applicationConditionEvaluation" );
616+ result = getActuatorDataFromOperation (connection , getObjectName (domain , "type=Endpoint,name=Conditions" ), "applicationConditionEvaluation" );
609617 if (result != null ) {
610618 String report = gson .toJson (result );
611619 return LiveConditionalParser .parse (report , processId , processName );
@@ -621,7 +629,7 @@ public LiveConditional[] getConditionals(MBeanServerConnection connection, Strin
621629 } catch (IOException e ) {
622630 //ignore. Happens a lot when apps are stopped while we try to talk to them.
623631 } catch (Exception e ) {
624- // TODO Auto-generated catch block
632+ // ignore, might happen when communication with the running app is difficult
625633 }
626634
627635 return null ;
@@ -655,7 +663,6 @@ public String[] getActiveProfiles(MBeanServerConnection connection, String envir
655663 }
656664
657665 public LiveProperties getProperties (MBeanServerConnection connection , String environment ) throws Exception {
658-
659666 try {
660667 if (environment != null ) {
661668 return LivePropertiesJsonParser .parseProperties (environment );
@@ -666,21 +673,20 @@ public LiveProperties getProperties(MBeanServerConnection connection, String env
666673 return null ;
667674 }
668675
669-
670-
671676 public String getEnvironment (MBeanServerConnection connection , String domain ) throws Exception {
672677 try {
673- Object result = getActuatorDataFromAttribute (connection , getObjectName (domain , "type=Endpoint,name=environmentEndpoint " ), "Data " );
678+ Object result = getActuatorDataFromOperation (connection , getObjectName (domain , "type=Endpoint,name=Env " ), "environment " );
674679 if (result != null ) {
675680 String environment = gson .toJson (result );
676681 return environment ;
677682 }
678683
679- result = getActuatorDataFromOperation (connection , getObjectName (domain , "type=Endpoint,name=Env " ), "environment " );
684+ result = getActuatorDataFromAttribute (connection , getObjectName (domain , "type=Endpoint,name=environmentEndpoint " ), "Data " );
680685 if (result != null ) {
681686 String environment = gson .toJson (result );
682687 return environment ;
683688 }
689+
684690 } catch (IOException e ) {
685691 //ignore... probably just because app is stopped
686692 } catch (ExecutionException e ) {
@@ -700,6 +706,9 @@ private Object getActuatorDataFromAttribute(MBeanServerConnection connection, Ob
700706 catch (InstanceNotFoundException |IOException e ) {
701707 return null ;
702708 }
709+ catch (ReflectionException e ) {
710+ return null ;
711+ }
703712 }
704713 return null ;
705714 }
@@ -712,6 +721,9 @@ private Object getActuatorDataFromOperation(MBeanServerConnection connection, Ob
712721 catch (InstanceNotFoundException |IOException e ) {
713722 return null ;
714723 }
724+ catch (ReflectionException e ) {
725+ return null ;
726+ }
715727 }
716728 return null ;
717729 }
@@ -724,6 +736,9 @@ private Object getActuatorDataFromOperation(MBeanServerConnection connection, Ob
724736 catch (InstanceNotFoundException |IOException e ) {
725737 return null ;
726738 }
739+ catch (ReflectionException e ) {
740+ return null ;
741+ }
727742 }
728743 return null ;
729744 }
0 commit comments