Skip to content

Commit f787ea4

Browse files
committed
make jackson factory instantiation native friendly
1 parent dfb48fe commit f787ea4

File tree

1 file changed

+7
-4
lines changed
  • google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2

1 file changed

+7
-4
lines changed

google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939
public final class JacksonFactory extends JsonFactory {
4040

4141
/** JSON factory. */
42-
private final com.fasterxml.jackson.core.JsonFactory factory =
43-
new com.fasterxml.jackson.core.JsonFactory();
42+
private final com.fasterxml.jackson.core.JsonFactory factory;
4443

45-
{
44+
public JacksonFactory() {
45+
factory = new com.fasterxml.jackson.core.JsonFactory();
4646
// don't auto-close JSON content in order to ensure consistent behavior across JSON factories
4747
// TODO(rmistry): Should we disable the JsonGenerator.Feature.AUTO_CLOSE_TARGET feature?
4848
factory.configure(
@@ -60,7 +60,10 @@ public static JacksonFactory getDefaultInstance() {
6060

6161
/** Holder for the result of {@link #getDefaultInstance()}. */
6262
static class InstanceHolder {
63-
static final JacksonFactory INSTANCE = new JacksonFactory();
63+
static final JacksonFactory INSTANCE;
64+
static {
65+
INSTANCE = new JacksonFactory();
66+
}
6467
}
6568

6669
@Override

0 commit comments

Comments
 (0)