Skip to content

Commit

Permalink
Fix #653
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Nov 14, 2020
1 parent 9f2ca7f commit 67c48f7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Expand Up @@ -30,6 +30,7 @@ JSON library.
#631: Add `JsonParser.getNumberValueExact()` to allow precision-retaining buffering
#639: Limit initial allocated block size by `ByteArrayBuilder` to max block size
#640: Add `JacksonException` as parent class of `JsonProcessingException`
#653: Make `JsonWriteContext.reset()` and `JsonReadContext.reset()` methods public
- Deprecate `JsonParser.getCurrentTokenId()` (use `#currentTokenId()` instead)
- Full "LICENSE" included in jar for easier access by compliancy tools

Expand Down
20 changes: 14 additions & 6 deletions src/main/java/com/fasterxml/jackson/core/json/JsonReadContext.java
Expand Up @@ -15,17 +15,16 @@ public final class JsonReadContext extends JsonStreamContext
* Parent context for this context; null for root context.
*/
protected final JsonReadContext _parent;

// // // Optional duplicate detection

protected DupDetector _dups;

/*
/**********************************************************
/* Simple instance reuse slots; speeds up things
/* a bit (10-15%) for docs with lots of small
/* arrays/objects (for which allocation was
/* visible in profile stack frames)
/* Simple instance reuse slots; speeds up things a bit (10-15%)
/* for docs with lots of small arrays/objects (for which
/* allocation was visible in profile stack frames)
/**********************************************************
*/

Expand Down Expand Up @@ -63,7 +62,16 @@ public JsonReadContext(JsonReadContext parent, DupDetector dups, int type, int l
_index = -1;
}

protected void reset(int type, int lineNr, int colNr) {
/**
* Internal method to allow instance reuse: DO NOT USE unless you absolutely
* know what you are doing.
* Clears up state (including "current value"), changes type to one specified;
* resets current duplicate-detection state (if any).
* Parent link left as-is since it is {@code final}.
*<p>
* NOTE: Public since 2.12.
*/
public void reset(int type, int lineNr, int colNr) {
_type = type;
_index = -1;
_lineNr = lineNr;
Expand Down
Expand Up @@ -84,7 +84,16 @@ protected JsonWriteContext(int type, JsonWriteContext parent, DupDetector dups,
_currentValue = currValue;
}

protected JsonWriteContext reset(int type) {
/**
* Internal method to allow instance reuse: DO NOT USE unless you absolutely
* know what you are doing.
* Clears up state (including "current value"), changes type to one specified;
* resets current duplicate-detection state (if any).
* Parent link left as-is since it is {@code final}.
*<p>
* NOTE: Public since 2.12.
*/
public JsonWriteContext reset(int type) {
_type = type;
_index = -1;
_currentName = null;
Expand All @@ -94,8 +103,18 @@ protected JsonWriteContext reset(int type) {
return this;
}

/* @since 2.10 */
protected JsonWriteContext reset(int type, Object currValue) {
/**
* Internal method to allow instance reuse: DO NOT USE unless you absolutely
* know what you are doing.
* Clears up state, changes type to one specified, assigns "current value";
* resets current duplicate-detection state (if any).
* Parent link left as-is since it is {@code final}.
*<p>
* NOTE: Public since 2.12.
*
* @since 2.10
*/
public JsonWriteContext reset(int type, Object currValue) {
_type = type;
_index = -1;
_currentName = null;
Expand Down
@@ -1,6 +1,5 @@
package com.fasterxml.jackson.core.filter;

import java.io.StringWriter;
import java.math.BigInteger;
import java.util.*;

Expand Down Expand Up @@ -367,8 +366,6 @@ public void testNoMatchFiltering3() throws Exception
String result = readAndWrite(JSON_F, p);
assertEquals(aposToQuotes("[[{'array':[],'ob':{}}],[{'array':[],'ob':{}}],[{'array':[],'ob':{}}]]"), result);
assertEquals(0, p.getMatchCount());

StringWriter w = new StringWriter();
}

public void testNoMatchFiltering4() throws Exception
Expand Down

0 comments on commit 67c48f7

Please sign in to comment.