fix(serialize-xml): interpret empty value wrapper as null

This commit is contained in:
Johannes Frohnmeyer 2024-04-20 16:39:50 +02:00
parent ae854cc040
commit 45eee07a29
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -29,7 +29,8 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
private static final int PEEKED_CDATA = 11;
private static final int PEEKED_NAME_VIRTUAL_TEXT = 12;
private static final int PEEKED_NAME_VIRTUAL_CDATA = 13;
private static final int PEEKED_EOF = 14;
private static final int PEEKED_NULL_VIRTUAL = 14;
private static final int PEEKED_EOF = 15;
int peeked = PEEKED_NONE;
private final NativeXmlReader reader;
@ -43,7 +44,7 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
private String nextTagName = null;
{
stack[stackSize++] = WrapperScope.DOCUMENT;
push(WrapperScope.DOCUMENT);
}
private void push(int newTop) {
@ -66,6 +67,7 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
@Override
public XmlReader setLenient(boolean lenient) {
super.setLenient(lenient);
reader.setLenient(lenient);
return this;
}
@ -175,6 +177,7 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
case PEEKED_CDATA -> heuristics.guessValueKind(getPath(), XmlToken.CDATA);
case PEEKED_ATT_VALUE -> heuristics.guessValueKind(getPath(), XmlToken.ATTRIBUTE_VALUE);
case PEEKED_TEXT -> heuristics.guessValueKind(getPath(), XmlToken.TEXT);
case PEEKED_NULL_VIRTUAL -> Token.NULL;
case PEEKED_EOF -> Token.END_DOCUMENT;
default -> throw new AssertionError();
};
@ -259,6 +262,11 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
reader.endTag();
yield doPeek();
}
case WrapperScope.OBJECT_VALUE_WRAPPER -> {
stackSize--;
reader.endTag();
yield PEEKED_NULL_VIRTUAL;
}
default -> throw syntaxError("Unexpected end tag");
};
case EOF -> PEEKED_EOF;
@ -373,6 +381,7 @@ public class XmlReader extends SerializeReader<IOException, XmlReader> implement
}
yield reader.nextCData();
}
case PEEKED_NULL_VIRTUAL -> "null";
default -> throw unexpectedTokenError(kind);
};
peeked = PEEKED_NONE;