From e2f509491f3eee10dcb4475824fbf5aac10fe38b Mon Sep 17 00:00:00 2001 From: moudatsos Date: Thu, 25 Jun 2020 00:10:10 +0300 Subject: [PATCH] Fix value data-type & entry-set order issues of properties bound to Map (#554) * Fix value data-type & entry-set order issues of properties bound to Map Issue: properties bound to a java.util.Map object do not maintain their definition order and their values lose their data-type, since they 're converted to String values. This fix mainly targets org.springframework.cloud.kubernetes.config .PropertySourceUtils.PROPERTIES_TO_MAP implementation: Configuration properties that are bound to a java.util.Map had their value's type affected by the use of .toString() on each entry's value during Map entry processing. Moreover, the use of java.util.stream .Collectors.toMap(java.util.function.Function, java.util.function.Function) when processing Map-bound properties, resulted in losing the entry insertion order of the original Map. The fix entails usage of the origina lentry value and a Collectors.toMap() variant that maintains the behavior of the method previously used, yet uses a java.util.LinkedHashMap as the target data structure for the processed entries. Ramification changes on method signature and return type have been applied where needed. * applying checkstyle * updated unit tests to account for the property loading behavior that maintains intended value data type * updated unit tests to account for the property loading behavior that maintains intended value data type * reverting test changes that target .properties files. Current fix targets only properties loaded from .yml files. org.springframework.cloud.kubernetes.config .PropertySourceUtils.KEY_VALUE_TO_PROPERTIES should be altered in order to address the same problem for configuration properties loaded from .properties files Co-authored-by: Michael Moudatsos