You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by rm...@apache.org on 2017/06/24 12:34:41 UTC

johnzon git commit: JOHNZON-128 thanks to James Carman for this patch fixing checkstyle

Repository: johnzon
Updated Branches:
  refs/heads/master d5ba838e4 -> adf8b6e8f


JOHNZON-128 thanks to James Carman for this patch fixing checkstyle


Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/adf8b6e8
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/adf8b6e8
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/adf8b6e8

Branch: refs/heads/master
Commit: adf8b6e8f86db696571a693174a604a0144cd8bf
Parents: d5ba838
Author: rmannibucau <rm...@apache.org>
Authored: Sat Jun 24 14:34:22 2017 +0200
Committer: rmannibucau <rm...@apache.org>
Committed: Sat Jun 24 14:34:22 2017 +0200

----------------------------------------------------------------------
 .../apache/johnzon/jsonb/JohnzonBuilder.java    | 42 +++++++++++---------
 1 file changed, 23 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/johnzon/blob/adf8b6e8/johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/JohnzonBuilder.java
----------------------------------------------------------------------
diff --git a/johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/JohnzonBuilder.java b/johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/JohnzonBuilder.java
index a84cf42..b3a55cb 100644
--- a/johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/JohnzonBuilder.java
+++ b/johnzon-jsonb/src/main/java/org/apache/johnzon/jsonb/JohnzonBuilder.java
@@ -119,25 +119,7 @@ public class JohnzonBuilder implements JsonbBuilder {
             builder.setGeneratorFactory(jsonp.createGeneratorFactory(generatorConfig()));
             builder.setReaderFactory(jsonp.createReaderFactory(readerConfig()));
         }
-        final Supplier<JsonParserFactory> parserFactoryProvider = new Supplier<JsonParserFactory>() { // thread safety is not mandatory
-            private final AtomicReference<JsonParserFactory> ref = new AtomicReference<>();
-
-            @Override
-            public JsonParserFactory get() {
-                JsonParserFactory factory = ref.get();
-                if (factory == null) {
-                    factory = doCreate();
-                    if (!ref.compareAndSet(null, factory)) {
-                        factory = ref.get();
-                    }
-                }
-                return factory;
-            }
-
-            private JsonParserFactory doCreate() {
-                return (jsonp == null ? JsonProvider.provider() : jsonp).createParserFactory(emptyMap());
-            }
-        };
+        final Supplier<JsonParserFactory> parserFactoryProvider = createJsonParserFactory();
 
         if (config == null) {
             config = new JsonbConfig();
@@ -366,6 +348,28 @@ public class JohnzonBuilder implements JsonbBuilder {
         } : new JohnsonJsonb(mapper);
     }
 
+    private Supplier<JsonParserFactory> createJsonParserFactory() {
+        return new Supplier<JsonParserFactory>() { // thread safety is not mandatory
+                private final AtomicReference<JsonParserFactory> ref = new AtomicReference<>();
+
+                @Override
+                public JsonParserFactory get() {
+                    JsonParserFactory factory = ref.get();
+                    if (factory == null) {
+                        factory = doCreate();
+                        if (!ref.compareAndSet(null, factory)) {
+                            factory = ref.get();
+                        }
+                    }
+                    return factory;
+                }
+
+                private JsonParserFactory doCreate() {
+                    return (jsonp == null ? JsonProvider.provider() : jsonp).createParserFactory(emptyMap());
+                }
+            };
+    }
+
     private ParameterizedType findPT(final Object s, final Class<?> type) {
         return ParameterizedType.class.cast(
                 Stream.of(s.getClass().getGenericInterfaces())