Author: kwright Date: Tue Mar 13 21:10:09 2018 New Revision: 1826683 URL: http://svn.apache.org/viewvc?rev=1826683&view=rev Log: CONNECTORS-1499: Use alternate representation more readily
Modified: manifoldcf/trunk/CHANGES.txt manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/Configuration.java Modified: manifoldcf/trunk/CHANGES.txt URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1826683&r1=1826682&r2=1826683&view=diff ============================================================================== --- manifoldcf/trunk/CHANGES.txt (original) +++ manifoldcf/trunk/CHANGES.txt Tue Mar 13 21:10:09 2018 @@ -3,6 +3,13 @@ $Id$ ======================= 2.10-dev ===================== +CONNECTORS-1499: Reading in JSON in exported format did not +preserve the order because the new JSON parser does things in +hash order for keys in objects. The fix is to use the more verbose +alternate form if there's any possibility of order dependency being +needed. +(Karl Wright) + CONNECTORS-1493: Jira connector could not fetch acls. (Damien Collis, Karl Wright) Modified: manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/Configuration.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/Configuration.java?rev=1826683&r1=1826682&r2=1826683&view=diff ============================================================================== --- manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/Configuration.java (original) +++ manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/interfaces/Configuration.java Tue Mar 13 21:10:09 2018 @@ -176,6 +176,8 @@ public class Configuration implements IH // properly, and use an alternate representation if we should find it. Map<String,List<ConfigurationNode>> childMap = new HashMap<String,List<ConfigurationNode>>(); List<String> childList = new ArrayList<String>(); + // The new JSON parser uses hash order for object keys. So it isn't good enough to just detect that there's an + // intermingling. Instead we need to the existence of more that one key; that implies that we need to do order preservation. String lastChildType = null; boolean needAlternate = false; int i = 0; @@ -186,17 +188,16 @@ public class Configuration implements IH List<ConfigurationNode> list = childMap.get(key); if (list == null) { + // We found no existing list, so create one list = new ArrayList<ConfigurationNode>(); childMap.put(key,list); childList.add(key); } - else + // Key order comes into play when we have elements of different types within the same child. + if (lastChildType != null && !lastChildType.equals(key)) { - if (!lastChildType.equals(key)) - { - needAlternate = true; - break; - } + needAlternate = true; + break; } list.add(child); lastChildType = key;