Revert "Revert "Upgrade jackson to 2.15.3 and snakeyaml to 2.1""

This reverts commit 8cd0690c0b.
This commit is contained in:
Brandon Williams 2023-12-01 12:40:51 -06:00
parent d91997cb04
commit 7204bc45b6
5 changed files with 36 additions and 24 deletions

View File

@ -427,27 +427,27 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.2</version>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.2.2</version>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.13.2</version>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.2</version>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.13.2</version>
<version>2.15.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
@ -469,7 +469,7 @@
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.26</version>
<version>2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>

View File

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

View File

@ -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<Class<?>, Map<String, Replacement>> 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;
}
}

View File

@ -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<String, Info> 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);
}

View File

@ -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);