Source:
protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); final PathAddress operationAddress = PathAddress.pathAddress(operation.get(OP_ADDR)); final PathAddress discoveryOptionsAddress = operationAddress.subAddress(0, operationAddress.size() - 1); final ModelNode discoveryOptions = Resource.Tools.readModel(context.readResourceFromRoot(discoveryOptionsAddress)); final ModelNode currentList = discoveryOptions.get(ModelDescriptionConstants.OPTIONS); final String name = operationAddress.getLastElement().getValue(); ModelNode element = currentList.asList().stream().filter(new Predicate<ModelNode>() { @Override public boolean test(ModelNode t) { ModelNode element = (ModelNode) t; final Property prop = element.asProperty(); final String discoveryOptionType = prop.getName(); final String discoveryOptionName = prop.getValue().get(ModelDescriptionConstants.NAME).asString(); return discoveryOptionType.equals(ModelDescriptionConstants.STATIC_DISCOVERY) && discoveryOptionName.equals(name); } }).findFirst().get(); final ModelNode node = element.get(ModelDescriptionConstants.STATIC_DISCOVERY); node.get(attributeName).set(newValue); final ModelNode writeOp = Util.getWriteAttributeOperation(discoveryOptionsAddress, ModelDescriptionConstants.OPTIONS, currentList); final OperationStepHandler writeHandler = context.getRootResourceRegistration().getSubModel(discoveryOptionsAddress).getOperationHandler(PathAddress.EMPTY_ADDRESS, WRITE_ATTRIBUTE_OPERATION); context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true); }

Target:
protected void finishModelStage(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode oldValue, Resource model) throws OperationFailedException { super.finishModelStage(context, operation, attributeName, newValue, oldValue, model); final PathAddress operationAddress = context.getCurrentAddress(); final PathAddress discoveryOptionsAddress = operationAddress.getParent(); final ModelNode discoveryOptions = context.readResourceFromRoot(discoveryOptionsAddress, false).getModel(); final ModelNode currentListClone = discoveryOptions.get(ModelDescriptionConstants.OPTIONS).clone(); final String name = context.getCurrentAddressValue(); for (ModelNode element : currentListClone.asList()) { final Property prop = element.asProperty(); final String discoveryOptionType = prop.getName(); final String discoveryOptionName = prop.getValue().get(ModelDescriptionConstants.NAME).asString(); if ( discoveryOptionName.equals(name) && discoveryOptionType.equals(ModelDescriptionConstants.STATIC_DISCOVERY)) { final ModelNode node = element.get(ModelDescriptionConstants.STATIC_DISCOVERY); node.get(attributeName).set(newValue); break; } } final ModelNode writeOp = Util.getWriteAttributeOperation(discoveryOptionsAddress, ModelDescriptionConstants.OPTIONS, currentListClone); final OperationStepHandler writeHandler = context.getRootResourceRegistration().getSubModel(discoveryOptionsAddress).getOperationHandler(PathAddress.EMPTY_ADDRESS, WRITE_ATTRIBUTE_OPERATION); context.addStep(writeOp, writeHandler, OperationContext.Stage.MODEL, true); }