Deprecated SnakeYAML methods (#3079)

I replaced the deprecated methods in SnakeYAML 1.33 with the respective non-deprecated constructor calls.
These are equivalent:
The deprecated non-arg constructor of Constructor https://bitbucket.org/snakeyaml/snakeyaml/src/snakeyaml-1.33/src/main/java/org/yaml/snakeyaml/constructor/Constructor.java
calls 7f5106920d/src/main/java/org/yaml/snakeyaml/constructor/SafeConstructor.java (lines-52), which uses a new empty LoaderOptions()

Similarly, SafeRepresenter 7f5106920d/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java (lines-54) uses a new empty DumperOptions.
This commit is contained in:
Marc Miltenberger 2023-05-27 19:20:57 +02:00 committed by GitHub
parent e53869ceba
commit 636b1a128e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package brut.androlib.meta;
import org.yaml.snakeyaml.constructor.AbstractConstruct; import org.yaml.snakeyaml.constructor.AbstractConstruct;
import org.yaml.snakeyaml.constructor.Constructor; import org.yaml.snakeyaml.constructor.Constructor;
import org.yaml.snakeyaml.error.YAMLException; import org.yaml.snakeyaml.error.YAMLException;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.nodes.ScalarNode; import org.yaml.snakeyaml.nodes.ScalarNode;
import org.yaml.snakeyaml.nodes.Tag; import org.yaml.snakeyaml.nodes.Tag;
@ -29,6 +30,7 @@ public class ClassSafeConstructor extends Constructor {
protected final List<Class<?>> allowableClasses = new ArrayList<>(); protected final List<Class<?>> allowableClasses = new ArrayList<>();
public ClassSafeConstructor() { public ClassSafeConstructor() {
super(new LoaderOptions());
this.yamlConstructors.put(Tag.STR, new ConstructStringEx()); this.yamlConstructors.put(Tag.STR, new ConstructStringEx());
this.allowableClasses.add(MetaInfo.class); this.allowableClasses.add(MetaInfo.class);

View File

@ -16,11 +16,13 @@
*/ */
package brut.androlib.meta; package brut.androlib.meta;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.nodes.Node; import org.yaml.snakeyaml.nodes.Node;
import org.yaml.snakeyaml.representer.Representer; import org.yaml.snakeyaml.representer.Representer;
public class EscapedStringRepresenter extends Representer { public class EscapedStringRepresenter extends Representer {
public EscapedStringRepresenter() { public EscapedStringRepresenter() {
super(new DumperOptions());
RepresentStringEx representStringEx = new RepresentStringEx(); RepresentStringEx representStringEx = new RepresentStringEx();
multiRepresenters.put(String.class, representStringEx); multiRepresenters.put(String.class, representStringEx);
representers.put(String.class, representStringEx); representers.put(String.class, representStringEx);