diff --git a/.build/parent-pom-template.xml b/.build/parent-pom-template.xml index 6e12bf0129..c2b23a4ca9 100644 --- a/.build/parent-pom-template.xml +++ b/.build/parent-pom-template.xml @@ -427,27 +427,27 @@ com.fasterxml.jackson.core jackson-core - 2.13.2 + 2.15.3 com.fasterxml.jackson.core jackson-databind - 2.13.2.2 + 2.15.3 com.fasterxml.jackson.core jackson-annotations - 2.13.2 + 2.15.3 com.fasterxml.jackson.datatype jackson-datatype-jsr310 - 2.13.2 + 2.15.3 com.fasterxml.jackson.dataformat jackson-dataformat-yaml - 2.13.2 + 2.15.3 test @@ -469,7 +469,7 @@ org.yaml snakeyaml - 1.26 + 2.1 junit diff --git a/CHANGES.txt b/CHANGES.txt index 1e690b42cb..a8c465c72a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 5.1 * Make nodetool tablestats use number of significant digits for time and average values consistently (CASSANDRA-19015) + * Upgrade jackson to 2.15.3 and snakeyaml to 2.1 (CASSANDRA-18875) * Transactional Cluster Metadata [CEP-21] (CASSANDRA-18330) * Add ELAPSED command to cqlsh (CASSANDRA-18861) * Add the ability to disable bulk loading of SSTables (CASSANDRA-18781) diff --git a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java index edff7be8ec..a312aa47dd 100644 --- a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java +++ b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java @@ -52,6 +52,8 @@ import org.yaml.snakeyaml.introspector.MissingProperty; import org.yaml.snakeyaml.introspector.Property; import org.yaml.snakeyaml.introspector.PropertyUtils; import org.yaml.snakeyaml.nodes.Node; +import org.yaml.snakeyaml.parser.ParserImpl; +import org.yaml.snakeyaml.resolver.Resolver; import static org.apache.cassandra.config.CassandraRelevantProperties.ALLOW_DUPLICATE_CONFIG_KEYS; import static org.apache.cassandra.config.CassandraRelevantProperties.ALLOW_NEW_OLD_CONFIG_KEYS; @@ -195,7 +197,7 @@ public class YamlConfigurationLoader implements ConfigurationLoader private static void verifyReplacements(Map, Map> replacements, byte[] configBytes) { - LoaderOptions loaderOptions = new LoaderOptions(); + LoaderOptions loaderOptions = getDefaultLoaderOptions(); loaderOptions.setAllowDuplicateKeys(ALLOW_DUPLICATE_CONFIG_KEYS.getBoolean()); Yaml rawYaml = new Yaml(loaderOptions); @@ -222,14 +224,7 @@ public class YamlConfigurationLoader implements ConfigurationLoader constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Node node = yaml.represent(map); - constructor.setComposer(new Composer(null, null) - { - @Override - public Node getSingleNode() - { - return node; - } - }); + constructor.setComposer(getDefaultComposer(node)); T value = (T) constructor.getSingleData(klass); if (shouldCheck) propertiesChecker.check(); @@ -256,18 +251,23 @@ public class YamlConfigurationLoader implements ConfigurationLoader constructor.setPropertyUtils(propertiesChecker); Yaml yaml = new Yaml(constructor); Node node = yaml.represent(map); - constructor.setComposer(new Composer(null, null) + constructor.setComposer(getDefaultComposer(node)); + T value = (T) constructor.getSingleData(klass); + if (shouldCheck) + propertiesChecker.check(); + return value; + } + + private static Composer getDefaultComposer(Node node) + { + return new Composer(new ParserImpl(null), new Resolver(), getDefaultLoaderOptions()) { @Override public Node getSingleNode() { return node; } - }); - T value = (T) constructor.getSingleData(klass); - if (shouldCheck) - propertiesChecker.check(); - return value; + }; } @VisibleForTesting @@ -275,7 +275,7 @@ public class YamlConfigurationLoader implements ConfigurationLoader { CustomConstructor(Class theRoot, ClassLoader classLoader) { - super(theRoot, classLoader); + super(theRoot, classLoader, getDefaultLoaderOptions()); TypeDescription seedDesc = new TypeDescription(ParameterizedClass.class); seedDesc.putMapPropertyType("parameters", String.class, String.class); @@ -426,5 +426,12 @@ public class YamlConfigurationLoader implements ConfigurationLoader logger.warn("{} parameters have been deprecated. They have new names and/or value format; For more information, please refer to NEWS.txt", deprecationWarnings); } } + + public static LoaderOptions getDefaultLoaderOptions() + { + LoaderOptions loaderOptions = new LoaderOptions(); + loaderOptions.setCodePointLimit(64 * 1024 * 1024); // 64 MiB + return loaderOptions; + } } diff --git a/src/java/org/apache/cassandra/tools/JMXTool.java b/src/java/org/apache/cassandra/tools/JMXTool.java index 8cf5748a2e..3e2fab5b3b 100644 --- a/src/java/org/apache/cassandra/tools/JMXTool.java +++ b/src/java/org/apache/cassandra/tools/JMXTool.java @@ -68,9 +68,11 @@ import io.airlift.airline.Command; import io.airlift.airline.Help; import io.airlift.airline.HelpOption; import io.airlift.airline.Option; +import org.apache.cassandra.config.YamlConfigurationLoader; import org.apache.cassandra.io.util.File; import org.apache.cassandra.io.util.FileInputStreamPlus; import org.apache.cassandra.utils.JsonUtils; +import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.TypeDescription; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; @@ -163,7 +165,7 @@ public class JMXTool { void dump(OutputStream output, Map map) throws IOException { - Representer representer = new Representer(); + Representer representer = new Representer(new DumperOptions()); representer.addClassTag(Info.class, Tag.MAP); // avoid the auto added tag Yaml yaml = new Yaml(representer); yaml.dump(map, new OutputStreamWriter(output)); @@ -394,6 +396,7 @@ public class JMXTool public CustomConstructor() { + super(YamlConfigurationLoader.getDefaultLoaderOptions()); this.rootTag = new Tag(ROOT); this.addTypeDescription(INFO_TYPE); } diff --git a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java index cc668b5ad4..598a4f327a 100644 --- a/tools/stress/src/org/apache/cassandra/stress/StressProfile.java +++ b/tools/stress/src/org/apache/cassandra/stress/StressProfile.java @@ -37,6 +37,7 @@ import com.google.common.util.concurrent.Uninterruptibles; import com.datastax.driver.core.*; import com.datastax.driver.core.exceptions.AlreadyExistsException; import org.antlr.runtime.RecognitionException; +import org.apache.cassandra.config.YamlConfigurationLoader; import org.apache.cassandra.cql3.CQLFragmentParser; import org.apache.cassandra.cql3.CqlParser; import org.apache.cassandra.cql3.statements.ModificationStatement; @@ -809,7 +810,7 @@ public class StressProfile implements Serializable { try { - Constructor constructor = new Constructor(StressYaml.class); + Constructor constructor = new Constructor(StressYaml.class, YamlConfigurationLoader.getDefaultLoaderOptions()); Yaml yaml = new Yaml(constructor);