Github user brosander commented on a diff in the pull request:

    https://github.com/apache/nifi-minifi/pull/33#discussion_r79609970
  
    --- Diff: 
minifi-commons/minifi-commons-schema/src/main/java/org/apache/nifi/minifi/commons/schema/ConfigSchema.java
 ---
    @@ -198,4 +305,31 @@ public ComponentStatusRepositorySchema 
getComponentStatusRepositoryProperties()
         public ProvenanceRepositorySchema getProvenanceRepositorySchema() {
             return provenanceRepositorySchema;
         }
    +
    +    public int getVersion() {
    +        return CONFIG_VERSION;
    +    }
    +
    +    /**
    +     * Will replace all characters not in [A-Za-z0-9_] with _
    +     * <p>
    +     * This has potential for collisions so it will also append numbers as 
necessary to prevent that
    +     *
    +     * @param ids  id map of already incremented numbers
    +     * @param name the name
    +     * @return a unique filesystem-friendly id
    +     */
    +    protected static String getUniqueId(Map<String, Integer> ids, String 
name) {
    +        String baseId = StringUtil.isNullOrEmpty(name) ? EMPTY_NAME : 
ID_REPLACE_PATTERN.matcher(name).replaceAll("_");
    +        String id = baseId;
    +        Integer idNum = ids.get(baseId);
    +        while (ids.containsKey(id)) {
    +            id = baseId + "_" + idNum++;
    +        }
    +        if (id != baseId) {
    --- End diff --
    
    @JPercivall I'm aware that most of the time this signals a bug, the 
assignment of id to baseId is only a few lines up, I'm just trying to see if it 
was reassigned in the while loop, meaning the reference equals should (and 
seems to based on testing) do the trick.
    
    I can change to a boolean flag if you think it would make things clearer.


---
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