Skip to content

Commit

Permalink
[WFCORE-7036] TransformationUtils.modelToResource() should not return…
Browse files Browse the repository at this point in the history
… undefined if possible children are not defined
  • Loading branch information
kabir committed Oct 24, 2024
1 parent e4bedf5 commit 78a22e8
Show file tree
Hide file tree
Showing 4 changed files with 682 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,6 @@ private static Resource modelToResource(final PathAddress startAddress, final Im
}
allFields.remove(name);
}
if (!value.isDefined() && model.isDefined() && reg.getChildAddresses(PathAddress.EMPTY_ADDRESS).isEmpty()) {
value.setEmptyObject();
}
res.writeModel(value);

for (String childType : reg.getChildNames(PathAddress.EMPTY_ADDRESS)) {
if (model.hasDefined(childType)) {
Expand All @@ -113,6 +109,12 @@ private static Resource modelToResource(final PathAddress startAddress, final Im
allFields.remove(childType);
}

if (!value.isDefined() && model.isDefined() && (reg.getChildAddresses(PathAddress.EMPTY_ADDRESS).isEmpty() || res.getChildTypes().isEmpty())) {
value.setEmptyObject();
}
res.writeModel(value);


if (!allFields.isEmpty()){
throw ControllerLogger.ROOT_LOGGER.modelFieldsNotKnown(allFields, startAddress.append(fullPath));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright The WildFly Authors
* SPDX-License-Identifier: Apache-2.0
*
*/

package org.jboss.as.subsystem.test;

import org.jboss.as.controller.registry.ImmutableManagementResourceRegistration;
import org.jboss.as.controller.registry.Resource;
import org.jboss.dmr.ModelNode;

/**
* For tests to call package protected methods in this package
*/
public class InternalPackageProtectedAccess {
public static Resource modelToResource(final ImmutableManagementResourceRegistration reg, final ModelNode model, boolean includeUndefined) {
return TransformationUtils.modelToResource(reg, model, includeUndefined);
}
}
Loading

0 comments on commit 78a22e8

Please sign in to comment.