OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] brooklyn-server pull request #968: does a yaml parse and compares the hash o...


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

    https://github.com/apache/brooklyn-server/pull/968#discussion_r192718263
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/typereg/RegisteredTypes.java ---
    @@ -682,27 +683,65 @@ private static String tagForEquivalentPlan(String input) {
             // it does mean a format change will be ignored
             return "equivalent-plan("+Streams.getMd5Checksum(Streams.newInputStreamWithContents(input.trim()))+")";
         }
    -    
    +
    +    /** parse the plan as yaml/json, re-serialize it, and take that checksum.
    +     * this allows plans that are equivalent post-parse to be treated as equivalent.
    +     * returns {@link Absent} if the input is not valid yaml.
    +     */
    +    private static Maybe<String> tagForEquivalentYamlPlan(String input) {
    +        // plans may be trimmed by yaml parser so do that before checking equivalence
    +        // it does mean a format change will be ignored
    +        try {
    +            Iterator<Object> plansI = Yamls.parseAll(input).iterator();
    +            if (!plansI.hasNext()) {
    +                return Maybe.absent("No data found");
    --- End diff --
    
    If we returned the tagForEquivalentPlan(input) here could we then simplify the arePlansEquivalent code?


---