Skip to content

Commit 4a13a2f

Browse files
authored
Make helper methods of WriterBasedJsonGenerator non-final to allow overriding (#1305)
1 parent 4607d0b commit 4a13a2f

3 files changed

Lines changed: 16 additions & 10 deletions

File tree

release-notes/CREDITS-2.x

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,7 @@ Antonin Janec (@xtonic)
438438
Jared Stehler (@jaredstehler)
439439
* Reported, contributed fix for #1274: `NUL`-corrupted keys, values on JSON serialization
440440
(2.18.0)
441+
442+
Zhanghao (@zhangOranges)
443+
* Contributed #1305: Make helper methods of `WriterBasedJsonGenerator` non-final to allow overriding
444+
(2.18.0)

release-notes/VERSION-2.x

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ a pure JSON library.
3333
#1274: `NUL`-corrupted keys, values on JSON serialization
3434
(reported, fix contributed by Jared S)
3535
#1277: Add back Java 22 optimisation in FastDoubleParser
36+
#1305: Make helper methods of `WriterBasedJsonGenerator` non-final to allow overriding
37+
(contributed by @zhangOranges)
3638

3739
2.17.2 (not yet released)
3840

src/main/java/com/fasterxml/jackson/core/json/WriterBasedJsonGenerator.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void writeFieldName(SerializableString name) throws IOException
166166
_writeFieldName(name, (status == JsonWriteContext.STATUS_OK_AFTER_COMMA));
167167
}
168168

169-
protected final void _writeFieldName(String name, boolean commaBefore) throws IOException
169+
protected void _writeFieldName(String name, boolean commaBefore) throws IOException
170170
{
171171
if (_cfgPrettyPrinter != null) {
172172
_writePPFieldName(name, commaBefore);
@@ -195,7 +195,7 @@ protected final void _writeFieldName(String name, boolean commaBefore) throws IO
195195
_outputBuffer[_outputTail++] = _quoteChar;
196196
}
197197

198-
protected final void _writeFieldName(SerializableString name, boolean commaBefore) throws IOException
198+
protected void _writeFieldName(SerializableString name, boolean commaBefore) throws IOException
199199
{
200200
if (_cfgPrettyPrinter != null) {
201201
_writePPFieldName(name, commaBefore);
@@ -230,7 +230,7 @@ protected final void _writeFieldName(SerializableString name, boolean commaBefor
230230
_outputBuffer[_outputTail++] = _quoteChar;
231231
}
232232

233-
private final void _writeFieldNameTail(SerializableString name) throws IOException
233+
protected void _writeFieldNameTail(SerializableString name) throws IOException
234234
{
235235
final char[] quoted = name.asQuotedChars();
236236
writeRaw(quoted, 0, quoted.length);
@@ -368,7 +368,7 @@ public void writeEndObject() throws IOException
368368

369369
// Specialized version of <code>_writeFieldName</code>, off-lined
370370
// to keep the "fast path" as simple (and hopefully fast) as possible.
371-
protected final void _writePPFieldName(String name, boolean commaBefore) throws IOException
371+
protected void _writePPFieldName(String name, boolean commaBefore) throws IOException
372372
{
373373
if (commaBefore) {
374374
_cfgPrettyPrinter.writeObjectEntrySeparator(this);
@@ -391,7 +391,7 @@ protected final void _writePPFieldName(String name, boolean commaBefore) throws
391391
}
392392
}
393393

394-
protected final void _writePPFieldName(SerializableString name, boolean commaBefore) throws IOException
394+
protected void _writePPFieldName(SerializableString name, boolean commaBefore) throws IOException
395395
{
396396
if (commaBefore) {
397397
_cfgPrettyPrinter.writeObjectEntrySeparator(this);
@@ -441,7 +441,7 @@ public void writeString(String text) throws IOException
441441
}
442442

443443
@Override
444-
public void writeString(Reader reader, final int len) throws IOException
444+
public void writeString(Reader reader, int len) throws IOException
445445
{
446446
_verifyValueWrite(WRITE_STRING);
447447
if (reader == null) {
@@ -939,7 +939,7 @@ public void writeNull() throws IOException {
939939
*/
940940

941941
@Override
942-
protected final void _verifyValueWrite(String typeMsg) throws IOException
942+
protected void _verifyValueWrite(String typeMsg) throws IOException
943943
{
944944
final int status = _writeContext.writeValue();
945945
if (_cfgPrettyPrinter != null) {
@@ -1586,7 +1586,7 @@ private void _writeStringCustom(char[] text, int offset, int len)
15861586
/**********************************************************
15871587
*/
15881588

1589-
protected final void _writeBinary(Base64Variant b64variant, byte[] input, int inputPtr, final int inputEnd)
1589+
protected void _writeBinary(Base64Variant b64variant, byte[] input, int inputPtr, final int inputEnd)
15901590
throws IOException, JsonGenerationException
15911591
{
15921592
// Encoding is by chunks of 3 input, 4 output chars, so:
@@ -1628,7 +1628,7 @@ protected final void _writeBinary(Base64Variant b64variant, byte[] input, int in
16281628
}
16291629

16301630
// write-method called when length is definitely known
1631-
protected final int _writeBinary(Base64Variant b64variant,
1631+
protected int _writeBinary(Base64Variant b64variant,
16321632
InputStream data, byte[] readBuffer, int bytesLeft)
16331633
throws IOException, JsonGenerationException
16341634
{
@@ -1688,7 +1688,7 @@ protected final int _writeBinary(Base64Variant b64variant,
16881688
}
16891689

16901690
// write method when length is unknown
1691-
protected final int _writeBinary(Base64Variant b64variant,
1691+
protected int _writeBinary(Base64Variant b64variant,
16921692
InputStream data, byte[] readBuffer)
16931693
throws IOException, JsonGenerationException
16941694
{

0 commit comments

Comments
 (0)