@Test public void testConcurrency() throws InterruptedException { final ExecutorService executor = Executors.newFixedThreadPool(NUM_THREADS); Query q = Builder.create() .addFieldClause( "kind", "foo") .addFieldClause( "name", "jane") .build(); for (int i = 0; i < 1000; i++) { final CountDownLatch start = new CountDownLatch(1); final TestContext finish = new TestContext(NUM_THREADS, Duration.ofSeconds(30)); final JsonMapper mapper = new JsonMapper(); for (int j = 0; j < NUM_THREADS; j++) { executor.execute(() -> { try { start.await(); mapper.toJson(q); finish.complete(); } catch (Throwable t) { finish.fail(t); } }); } start.countDown(); finish.await(); } }
public String toJson(Object body) { for (int i = 1; ; i++) { try { return this.compact.toJson(body); } catch (IllegalStateException e) { handleIllegalStateException(e, i); } } }
JsonMapper { public String toJson(Object body) { for (int i = 1; ; i++) { try { return this.compact.toJson(body); } catch (IllegalStateException e) { handleIllegalStateException(e, i); } } } }
JsonMapper { public String toJson(Object body) { for (int i = 1; ; i++) { try { return this.compact.toJson(body); } catch (IllegalStateException e) { handleIllegalStateException(e, i); } } } JsonMapper();  JsonMapper(Consumer<GsonBuilder> gsonConfigCallback);  JsonMapper(Gson compact, Gson compactSensitive); }
JsonMapper { public String toJson(Object body) { for (int i = 1; ; i++) { try { return this.compact.toJson(body); } catch (IllegalStateException e) { handleIllegalStateException(e, i); } } } JsonMapper();  JsonMapper(Consumer<GsonBuilder> gsonConfigCallback);  JsonMapper(Gson compact, Gson compactSensitive); String toJson(Object body); void toJson(Object body, Appendable appendable); JsonElement toJsonElement(Object body); String toJsonHtml(Object body); void toJson(Set<JsonOptions> options, Object body, Appendable appendable); T fromJson(Object json, Class<T> clazz); T fromJson(Object json, Type type); void setJsonSuppressGsonSerializationErrors(boolean suppressErrors); static GsonBuilder createDefaultGsonBuilder(EnumSet<JsonOptions> options); void toJsonHtml(Object body, Appendable appendable); long hashJson(Object body, long seed); }
JsonMapper { public String toJson(Object body) { for (int i = 1; ; i++) { try { return this.compact.toJson(body); } catch (IllegalStateException e) { handleIllegalStateException(e, i); } } } JsonMapper();  JsonMapper(Consumer<GsonBuilder> gsonConfigCallback);  JsonMapper(Gson compact, Gson compactSensitive); String toJson(Object body); void toJson(Object body, Appendable appendable); JsonElement toJsonElement(Object body); String toJsonHtml(Object body); void toJson(Set<JsonOptions> options, Object body, Appendable appendable); T fromJson(Object json, Class<T> clazz); T fromJson(Object json, Type type); void setJsonSuppressGsonSerializationErrors(boolean suppressErrors); static GsonBuilder createDefaultGsonBuilder(EnumSet<JsonOptions> options); void toJsonHtml(Object body, Appendable appendable); long hashJson(Object body, long seed); static final String PROPERTY_JSON_SUPPRESS_GSON_SERIALIZATION_ERRORS; }