Github user jaredjstewart commented on a diff in the pull request:
https://github.com/apache/geode/pull/671#discussion_r130668398
--- Diff:
geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
---
@@ -1143,4 +721,26 @@ private boolean
isAttributePersistent(RegionAttributes attributes) {
return attributes != null && attributes.getDataPolicy() != null
&& attributes.getDataPolicy().toString().contains("PERSISTENT");
}
+
+ private static boolean regionExists(InternalCache cache, String
regionPath) {
--- End diff --
I don't see any tests that validate the behavior of this method. I think
we can simplify it to:
```
private static boolean regionExists(InternalCache cache, String regionPath)
{
if (regionPath == null || Region.SEPARATOR.equals(regionPath)) {
return false;
}
ManagementService managementService =
ManagementService.getExistingManagementService(cache);
DistributedSystemMXBean dsMBean =
managementService.getDistributedSystemMXBean();
String[] allRegionPaths = dsMBean.listAllRegionPaths();
return Arrays.stream(allRegionPaths).anyMatch(regionPath::equals);
}
```
But it would be nice to have a test that would fail with this
implementation:
```
private static boolean regionExists(InternalCache cache, String regionPath)
{
return true;
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---