Github user dschneider-pivotal commented on a diff in the pull request:

    https://github.com/apache/incubator-geode/pull/201#discussion_r71577700
  
    --- Diff: 
geode-core/src/main/java/com/gemstone/gemfire/internal/cache/LocalRegion.java 
---
    @@ -7769,17 +7879,55 @@ void cleanUpOnIncompleteOp(EntryEventImpl event, 
RegionEntry re) {
         this.entries.removeEntry(event.getKey(), re, false) ;      
       }
     
    -  static void validateRegionName(String name)
    +  static void validateRegionName(String name, InternalRegionArguments 
internalRegionArgs)
       {
         if (name == null) {
           throw new 
IllegalArgumentException(LocalizedStrings.LocalRegion_NAME_CANNOT_BE_NULL.toLocalizedString());
         }
    -    if (name.length() == 0) {
    +    if (name.isEmpty()) {
           throw new 
IllegalArgumentException(LocalizedStrings.LocalRegion_NAME_CANNOT_BE_EMPTY.toLocalizedString());
         }
    -    if (name.indexOf(SEPARATOR) >= 0) {
    +    if (name.contains(SEPARATOR)) {
           throw new 
IllegalArgumentException(LocalizedStrings.LocalRegion_NAME_CANNOT_CONTAIN_THE_SEPARATOR_0.toLocalizedString(SEPARATOR));
         }
    +
    +    // Validate the name of the region only if it isn't an internal region
    +    if (internalRegionArgs.isInternalRegion()){
    +      return;
    +    }
    +    if (internalRegionArgs.isUsedForMetaRegion()) {
    +      return;
    +    }
    +    if (internalRegionArgs.isUsedForPartitionedRegionAdmin()) {
    +      return;
    +    }
    +    if (internalRegionArgs.isUsedForPartitionedRegionBucket()) {
    +      return;
    +    }
    +
    +//    LocalRegion metaRegion = internalRegionArgs.getInternalMetaRegion();
    +//    if (metaRegion != null) {
    +//      if (metaRegion instanceof HARegion) {
    +//        if (metaRegion.getName().equals(name)) {
    +//          return;
    +//        }
    +//      }
    +//      if (metaRegion instanceof SerialGatewaySenderQueueMetaRegion) {
    +//        return;
    +//      }
    +//    }
    +
    +    if (name.startsWith("__")
    +        && !name.equals(ClientHealthMonitoringRegion.ADMIN_REGION_NAME)) {
    +      throw new IllegalArgumentException("Region names may not begin with 
a double-underscore: " + name);
    +    }
    +
    +    // Ensure the region only contains valid characters
    +    Pattern pattern = Pattern.compile("[aA-zZ0-9-_.]+");
    --- End diff --
    
    Would it be worth putting this Pattern in a static final so that we don't 
compile it on every name check?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to