Skip to content

Commit

Permalink
Resolved conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
akats7 committed Jul 28, 2023
1 parent 88d30ae commit 54f09d4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,38 +98,36 @@ class MBeanHelper {
return mbeans
}

@PackageScope List<Object> getAttribute(String attribute) {
if (mbeans == null || mbeans.size() == 0) {
return []
}

def ofInterest = isSingle ? [mbeans[0]]: mbeans
@PackageScope List<Object> getAttribute(String attribute) {
if (mbeans == null || mbeans.size() == 0) {
return []
}

return ofInterest.collect {
try {
attributeTransformation.containsKey(attribute) ? attributeTransformation[attribute](it) : it.getProperty(attribute)
} catch (AttributeNotFoundException e) {
logger.warning("Expected attribute ${attribute} not found in mbean ${it.name()}")
null
}
}
def ofInterest = isSingle ? [mbeans[0]]: mbeans
return ofInterest.collect {
getBeanAttribute(it, attribute)
}
}

@PackageScope List<Tuple3<GroovyMBean, String, Object>> getAttributes(Set<String> attributes) {
if (mbeans == null || mbeans.size() == 0) {
return []
}
@PackageScope List<Tuple3<GroovyMBean, String, Object>> getAttributes(Set<String> attributes) {
if (mbeans == null || mbeans.size() == 0) {
return []
}

def ofInterest = isSingle ? [mbeans[0]]: mbeans
return [ofInterest, attributes].combinations().collect { pair ->
def (bean, attribute) = pair
try {
def extractedAttribute = attributeTransformation.containsKey(attribute) ? attributeTransformation[attribute](bean) : bean.getProperty(attribute)
new Tuple3(bean, attribute, extractedAttribute)
} catch (AttributeNotFoundException e) {
logger.info("Expected attribute ${attribute} not found in mbean ${bean.name()}")
new Tuple3(bean, attribute, null)
}
}
def ofInterest = isSingle ? [mbeans[0]]: mbeans
return [ofInterest, attributes].combinations().collect { pair ->
def (bean, attribute) = pair
new Tuple3(bean, attribute, getBeanAttribute(bean, attribute))
}
}

Object getBeanAttribute(GroovyMBean bean, String attribute) {
try {
def transformationClosure = attributeTransformation.get(attribute);
transformationClosure != null ? transformationClosure(bean) : bean.getProperty(attribute)
} catch (AttributeNotFoundException e) {
logger.warning("Expected attribute ${attribute} not found in mbean ${bean.name()}")
null
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
@Timeout(value = 10, unit = SECONDS)
class MBeanHelperTest {

// private static final Logger logger = Logger.getLogger(MBeanHelperTest.class.getName());
private static final MBeanServer mbeanServer = getPlatformMBeanServer();

private static final Set<ObjectInstance> registeredBeans = new HashSet<>();
Expand Down

0 comments on commit 54f09d4

Please sign in to comment.