Skip to content

Commit

Permalink
fix compilation problems after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
mariofusco committed Aug 22, 2023
1 parent de398d4 commit b6d5afe
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 16 deletions.
23 changes: 22 additions & 1 deletion src/main/java/com/fasterxml/jackson/core/JsonFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -2151,7 +2151,28 @@ protected JsonGenerator _decorate(JsonGenerator g) {
*/
public BufferRecycler _getBufferRecycler()
{
return _getBufferRecyclerPool().acquireBufferRecycler(this);
return _getBufferRecyclerPool().acquireBufferRecycler();
}

public static BufferRecycler _getDefaultBufferRecycler()
{
return BufferRecyclers.defaultRecyclerPool().acquireBufferRecycler();
}

/**
* Accessor for getting access to {@link BufferRecyclerPool} for getting
* {@link BufferRecycler} instance to use.
*
* @since 2.16
*/
public BufferRecyclerPool _getBufferRecyclerPool() {
// 23-Apr-2015, tatu: Let's allow disabling of buffer recycling
// scheme, for cases where it is considered harmful (possibly
// on Android, for example)
if (!Feature.USE_THREAD_LOCAL_FOR_BUFFER_RECYCLING.enabledIn(_factoryFeatures)) {
return BufferRecyclers.nopRecyclerPool();
}
return _bufferRecyclerPool;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/fasterxml/jackson/core/io/IOContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.core.ErrorReportConfiguration;
import com.fasterxml.jackson.core.JsonEncoding;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.StreamReadConstraints;
import com.fasterxml.jackson.core.StreamWriteConstraints;
import com.fasterxml.jackson.core.util.BufferRecycler;
Expand Down Expand Up @@ -142,27 +143,26 @@ public class IOContext implements AutoCloseable
public IOContext(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc,
ContentReference contentRef, boolean managedResource)
{
this(src, swc, erc, BufferRecyclerPool.acquireBufferRecycler(), contentRef, managedResource);
this(src, swc, erc, JsonFactory._getDefaultBufferRecycler(), contentRef, managedResource);
}

/**
* Main constructor to use.
*
* @param src constraints for streaming reads
* @param swc constraints for streaming writes
* @param erc Error report configuration to use
* @param br BufferRecycler to use, if any ({@code null} if none)
* @param contentRef Input source reference for location reporting
* @param managedResource Whether input source is managed (owned) by Jackson library
* @param erc Error report configuration to use
*
* @since 2.16
*/
@Deprecated
public IOContext(StreamReadConstraints src, StreamWriteConstraints swc, ErrorReportConfiguration erc,
BufferRecycler br, ContentReference contentRef, boolean managedResource)
{
_streamReadConstraints = (src == null) ?
StreamReadConstraints.defaults() : src;
_streamWriteConstraints = (swc == null) ?
StreamWriteConstraints.defaults() : swc;
_streamReadConstraints = src;
_streamWriteConstraints = swc;
_errorReportConfiguration = erc;
_bufferRecycler = br;
_contentReference = contentRef;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.fasterxml.jackson.core.util;

import com.fasterxml.jackson.core.TokenStreamFactory;

/**
* Interface for entity that controls creation and possible reuse of {@link BufferRecycler}
* instances used for recycling of underlying input/output buffers.
Expand All @@ -11,7 +9,7 @@
public interface BufferRecyclerPool
extends java.io.Serializable
{
public BufferRecycler acquireBufferRecycler(TokenStreamFactory forFactory);
public BufferRecycler acquireBufferRecycler();

public void releaseBufferRecycler(BufferRecycler recycler);
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public static class ThreadLocalRecyclerPool
public final static ThreadLocalRecyclerPool INSTANCE = new ThreadLocalRecyclerPool();

@Override
public BufferRecycler acquireBufferRecycler(TokenStreamFactory forFactory) {
public BufferRecycler acquireBufferRecycler() {
return getBufferRecycler();
}

Expand All @@ -238,7 +238,7 @@ public static class NonRecyclingRecyclerPool
public final static ThreadLocalRecyclerPool INSTANCE = new ThreadLocalRecyclerPool();

@Override
public BufferRecycler acquireBufferRecycler(TokenStreamFactory forFactory) {
public BufferRecycler acquireBufferRecycler() {
return new BufferRecycler();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.fasterxml.jackson.core.write;

import java.io.StringWriter;

import com.fasterxml.jackson.core.BaseTest;
import com.fasterxml.jackson.core.ErrorReportConfiguration;
import com.fasterxml.jackson.core.JsonGenerator;
Expand All @@ -10,7 +8,8 @@
import com.fasterxml.jackson.core.io.ContentReference;
import com.fasterxml.jackson.core.io.IOContext;
import com.fasterxml.jackson.core.json.WriterBasedJsonGenerator;
import com.fasterxml.jackson.core.util.BufferRecycler;

import java.io.StringWriter;

public class WriterBasedJsonGeneratorTest extends BaseTest
{
Expand Down

0 comments on commit b6d5afe

Please sign in to comment.