Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core#1015 non-blocking smile parser respects CANONICALIZE_FIELD_NAMES #378

Merged
merged 1 commit into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public NonBlockingByteArrayParser createNonBlockingByteArrayParser() throws IOEx
IOContext ctxt = _createContext(null, false);
// 13-Mar-2021, tatu: [dataformats-binary#252] Leave async parser with
// always-canonicalizing, for now (2.13) -- to be improved in future
ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChild(_factoryFeatures);
ByteQuadsCanonicalizer can = _byteSymbolCanonicalizer.makeChildOrPlaceholder(_factoryFeatures);
return new NonBlockingByteArrayParser(ctxt, _parserFeatures, _smileParserFeatures, can);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,10 @@ private final String _findDecodedLonger(byte[] inBuf, int inPtr, int len) throws

protected final String _addDecodedToSymbols(int len, String name) throws IOException
{
// 5-May-2023, ckozak: [core#1015] respect CANONICALIZE_FIELD_NAMES factory config.
if (!_symbolsCanonical) {
return name;
}
if (len < 5) {
return _symbols.addName(name, _quad1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.io.IOContext;
import com.fasterxml.jackson.core.io.ContentReference;
import com.fasterxml.jackson.dataformat.smile.async.NonBlockingByteArrayParser;

import static org.junit.Assert.assertArrayEquals;

Expand Down Expand Up @@ -153,6 +154,20 @@ public void testGeneratorConstruction() throws Exception
g.close();
}

public void testCanonicalization() throws Exception
{
try (NonBlockingByteArrayParser parser = new SmileFactory()
.createNonBlockingByteArrayParser()) {
assertTrue(parser._symbolsCanonical);
}
try (NonBlockingByteArrayParser parser = SmileFactory.builder()
.disable(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES)
.build()
.createNonBlockingByteArrayParser()) {
assertFalse(parser._symbolsCanonical);
}
}

/*
/**********************************************************
/* Helper methods
Expand Down