Skip to content

Commit

Permalink
Fix #1304: demote StreamReadConstraints from ParserBase to ParserMini…
Browse files Browse the repository at this point in the history
…malBase (#1306)
  • Loading branch information
cowtowncoder committed Jun 13, 2024
1 parent 7469684 commit 02b0859
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
18 changes: 4 additions & 14 deletions src/main/java/com/fasterxml/jackson/core/base/ParserBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,9 @@ public abstract class ParserBase extends ParserMinimalBase
*/
protected final IOContext _ioContext;

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

// Demoted to ParserMinimalBase in 2.18
//protected final StreamReadConstraints _streamReadConstraints;

/**
* Flag that indicates whether parser is closed or not. Gets
* set when parser is either closed by explicit call
Expand Down Expand Up @@ -267,11 +265,8 @@ public abstract class ParserBase extends ParserMinimalBase
*/

protected ParserBase(IOContext ctxt, int features) {
super(features);
super(features, ctxt.streamReadConstraints());
_ioContext = ctxt;
final StreamReadConstraints streamReadConstraints = ctxt.streamReadConstraints();
_streamReadConstraints = streamReadConstraints == null ?
StreamReadConstraints.defaults() : streamReadConstraints;
_textBuffer = ctxt.constructReadConstrainedTextBuffer();
DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
? DupDetector.rootDetector(this) : null;
Expand Down Expand Up @@ -873,11 +868,6 @@ public BigDecimal getDecimalValue() throws IOException
return _getBigDecimal();
}

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

/*
/**********************************************************
/* Conversion from textual to numeric representation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ public abstract class ParserMinimalBase extends JsonParser
@Deprecated
protected final static int MAX_ERROR_TOKEN_LENGTH = 256;

/*
/**********************************************************
/* Minimal configuration
/**********************************************************
*/

/**
* @since 2.18 (was higher up in {@code ParserBase} before)
*/
protected final StreamReadConstraints _streamReadConstraints;

/*
/**********************************************************
/* Minimal generally useful state
Expand All @@ -159,8 +170,21 @@ public abstract class ParserMinimalBase extends JsonParser
/**********************************************************
*/

protected ParserMinimalBase() { super(); }
protected ParserMinimalBase(int features) { super(features); }
@Deprecated // since 2.18
protected ParserMinimalBase() {
super();
_streamReadConstraints = StreamReadConstraints.defaults();
}

@Deprecated // since 2.18
protected ParserMinimalBase(int features) {
this(features, null);
}

protected ParserMinimalBase(int features, StreamReadConstraints src) {
super(features);
_streamReadConstraints = (src == null) ? StreamReadConstraints.defaults() : src;
}

// NOTE: had base impl in 2.3 and before; but shouldn't
// public abstract Version version();
Expand All @@ -178,6 +202,11 @@ public abstract class ParserMinimalBase extends JsonParser
//public void setFeature(Feature f, boolean state)
//public boolean isFeatureEnabled(Feature f)

@Override // @since 2.18 (demoted from ParserBase)
public StreamReadConstraints streamReadConstraints() {
return _streamReadConstraints;
}

/*
/**********************************************************
/* JsonParser impl
Expand Down

0 comments on commit 02b0859

Please sign in to comment.