Skip to content

Commit

Permalink
Changes to sync with core/1304 (StreamReadConstraints refactoring)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 13, 2024
1 parent 93ab77a commit c2af857
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;

import com.fasterxml.jackson.core.*;
Expand Down Expand Up @@ -315,11 +316,6 @@ private Feature(boolean defaultState) {
*/
protected ObjectCodec _objectCodec;

/**
* @since 2.15
*/
protected final StreamReadConstraints _streamReadConstraints;

/**
* @since 2.16
*/
Expand Down Expand Up @@ -433,29 +429,21 @@ private Feature(boolean defaultState) {
public CsvParser(IOContext ctxt, int stdFeatures, int csvFeatures,
ObjectCodec codec, Reader reader)
{
super(stdFeatures);
if (reader == null) {
throw new IllegalArgumentException("Can not pass `null` as `java.io.Reader` to read from");
}
super(stdFeatures, ctxt.streamReadConstraints());
Objects.requireNonNull(reader, "Can not pass `null` as `java.io.Reader` to read from");
_objectCodec = codec;
_ioContext = ctxt;
_streamReadConstraints = ctxt.streamReadConstraints();
_textBuffer = ctxt.constructReadConstrainedTextBuffer();
_formatFeatures = csvFeatures;
DupDetector dups = JsonParser.Feature.STRICT_DUPLICATE_DETECTION.enabledIn(stdFeatures)
? DupDetector.rootDetector(this) : null;
_formatFeatures = csvFeatures;
_parsingContext = JsonReadContext.createRootContext(dups);
_textBuffer = ctxt.constructReadConstrainedTextBuffer();
_reader = new CsvDecoder(this, ctxt, reader, _schema, _textBuffer,
stdFeatures, csvFeatures);
_cfgEmptyStringAsNull = CsvParser.Feature.EMPTY_STRING_AS_NULL.enabledIn(csvFeatures);
_cfgEmptyUnquotedStringAsNull = Feature.EMPTY_UNQUOTED_STRING_AS_NULL.enabledIn(csvFeatures);
}

@Override
public StreamReadConstraints streamReadConstraints() {
return _streamReadConstraints;
}

/*
/**********************************************************
/* Versioned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ public class JavaPropsParser extends ParserMinimalBase
*/
protected ObjectCodec _objectCodec;

/**
* @since 2.15
*/
protected final StreamReadConstraints _streamReadConstraints;

/**
* @since 2.16
*/
Expand Down Expand Up @@ -105,19 +100,13 @@ public JavaPropsParser(IOContext ctxt, Object inputSource,
public JavaPropsParser(IOContext ctxt, int parserFeatures, Object inputSource,
ObjectCodec codec, Map<?,?> sourceMap)
{
super(parserFeatures);
super(parserFeatures, ctxt.streamReadConstraints());
_ioContext = ctxt;
_streamReadConstraints = ctxt.streamReadConstraints();
_objectCodec = codec;
_inputSource = inputSource;
_sourceContent = sourceMap;
}

@Override
public StreamReadConstraints streamReadConstraints() {
return _streamReadConstraints;
}

@Override
public Version version() {
return PackageVersion.VERSION;
Expand Down Expand Up @@ -255,7 +244,7 @@ public JsonToken nextToken() throws IOException {
if (_readContext == null) { // end of content
return null;
}
_streamReadConstraints.validateNestingDepth(_readContext.getNestingDepth());
streamReadConstraints().validateNestingDepth(_readContext.getNestingDepth());
}
return _currToken;
}
Expand Down

0 comments on commit c2af857

Please sign in to comment.