Skip to content

Commit

Permalink
[WFCORE-6604] Avoid default value for arrays and TabularType
Browse files Browse the repository at this point in the history
  • Loading branch information
kabir committed Nov 15, 2023
1 parent 9ba02e7 commit 0903e92
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions jmx/src/main/java/org/jboss/as/jmx/model/MBeanInfoFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import javax.management.openmbean.OpenMBeanParameterInfoSupport;
import javax.management.openmbean.OpenType;
import javax.management.openmbean.SimpleType;
import javax.management.openmbean.TabularType;

import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.CompositeOperationHandler;
Expand Down Expand Up @@ -263,9 +264,16 @@ private OpenMBeanParameterInfo[] getParameterInfos(OperationDefinition opDef, Mo
boolean expressionsAllowed = value.hasDefined(EXPRESSIONS_ALLOWED) && value.get(EXPRESSIONS_ALLOWED).asBoolean();
descriptions.put(DESC_EXPRESSIONS_ALLOWED, String.valueOf(expressionsAllowed));

OpenType<?> mbeanType = converters.convertToMBeanType(attributeDefinition, value);
if (!expressionsAllowed) {
Object defaultValue = getIfExists(attributeDefinition, value, DEFAULT);
descriptions.put(DEFAULT_VALUE_FIELD, defaultValue);

// The OpenMBeanParameterInfoSupport constructor makes sure that arrays
// and TabularTypes do not have a default value. Avoid that exception
// by checking here and not adding a default value in this case.
if (!mbeanType.isArray() && !((Object)mbeanType instanceof TabularType) ) {
descriptions.put(DEFAULT_VALUE_FIELD, defaultValue);
}
if (value.has(ALLOWED)) {
if (value.get(TYPE).asType()!=ModelType.LIST){
List<ModelNode> allowed = value.get(ALLOWED).asList();
Expand All @@ -287,12 +295,11 @@ private OpenMBeanParameterInfo[] getParameterInfos(OperationDefinition opDef, Mo
}
}


params.add(
new OpenMBeanParameterInfoSupport(
paramName,
getDescription(value),
converters.convertToMBeanType(attributeDefinition, value),
mbeanType,
new ImmutableDescriptor(descriptions)));

}
Expand Down

0 comments on commit 0903e92

Please sign in to comment.