Skip to content

Commit 25c787d

Browse files
committed
Fix #1304: demote StreamReadConstraints from ParserBase to ParserMinimalBase
1 parent 7469684 commit 25c787d

File tree

2 files changed

+35
-16
lines changed

2 files changed

+35
-16
lines changed

src/main/java/com/fasterxml/jackson/core/base/ParserBase.java

+4-14
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ public abstract class ParserBase extends ParserMinimalBase
4141
*/
4242
protected final IOContext _ioContext;
4343

44-
/**
45-
* @since 2.15
46-
*/
47-
protected final StreamReadConstraints _streamReadConstraints;
48-
44+
// Demoted to ParserMinimalBase in 2.18
45+
//protected final StreamReadConstraints _streamReadConstraints;
46+
4947
/**
5048
* Flag that indicates whether parser is closed or not. Gets
5149
* set when parser is either closed by explicit call
@@ -267,11 +265,8 @@ public abstract class ParserBase extends ParserMinimalBase
267265
*/
268266

269267
protected ParserBase(IOContext ctxt, int features) {
270-
super(features);
268+
super(features, ctxt.streamReadConstraints());
271269
_ioContext = ctxt;
272-
final StreamReadConstraints streamReadConstraints = ctxt.streamReadConstraints();
273-
_streamReadConstraints = streamReadConstraints == null ?
274-
StreamReadConstraints.defaults() : streamReadConstraints;
275270
_textBuffer = ctxt.constructReadConstrainedTextBuffer();
276271
DupDetector dups = Feature.STRICT_DUPLICATE_DETECTION.enabledIn(features)
277272
? DupDetector.rootDetector(this) : null;
@@ -873,11 +868,6 @@ public BigDecimal getDecimalValue() throws IOException
873868
return _getBigDecimal();
874869
}
875870

876-
@Override // @since 2.15
877-
public StreamReadConstraints streamReadConstraints() {
878-
return _streamReadConstraints;
879-
}
880-
881871
/*
882872
/**********************************************************
883873
/* Conversion from textual to numeric representation

src/main/java/com/fasterxml/jackson/core/base/ParserMinimalBase.java

+31-2
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ public abstract class ParserMinimalBase extends JsonParser
134134
@Deprecated
135135
protected final static int MAX_ERROR_TOKEN_LENGTH = 256;
136136

137+
/*
138+
/**********************************************************
139+
/* Minimal configuration
140+
/**********************************************************
141+
*/
142+
143+
/**
144+
* @since 2.18 (was higher up in {@code ParserBase} before)
145+
*/
146+
protected final StreamReadConstraints _streamReadConstraints;
147+
137148
/*
138149
/**********************************************************
139150
/* Minimal generally useful state
@@ -159,8 +170,21 @@ public abstract class ParserMinimalBase extends JsonParser
159170
/**********************************************************
160171
*/
161172

162-
protected ParserMinimalBase() { super(); }
163-
protected ParserMinimalBase(int features) { super(features); }
173+
@Deprecated // since 2.18
174+
protected ParserMinimalBase() {
175+
super();
176+
_streamReadConstraints = StreamReadConstraints.defaults();
177+
}
178+
179+
@Deprecated // since 2.18
180+
protected ParserMinimalBase(int features) {
181+
this(features, null);
182+
}
183+
184+
protected ParserMinimalBase(int features, StreamReadConstraints src) {
185+
super(features);
186+
_streamReadConstraints = (src == null) ? StreamReadConstraints.defaults() : src;
187+
}
164188

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

205+
@Override // @since 2.18 (demoted from ParserBase)
206+
public StreamReadConstraints streamReadConstraints() {
207+
return _streamReadConstraints;
208+
}
209+
181210
/*
182211
/**********************************************************
183212
/* JsonParser impl

0 commit comments

Comments
 (0)