diff --git a/gson/src/main/java/com/google/gson/Gson.java b/gson/src/main/java/com/google/gson/Gson.java
index 1511bbb178..8e6df5b36a 100644
--- a/gson/src/main/java/com/google/gson/Gson.java
+++ b/gson/src/main/java/com/google/gson/Gson.java
@@ -756,6 +756,15 @@ public void toJson(JsonElement jsonElement, Appendable writer) throws JsonIOExce
/**
* Returns a new JSON writer configured for the settings on this Gson instance.
+ *
+ *
The following settings are considered:
+ *
+ * - {@link GsonBuilder#disableHtmlEscaping()}
+ * - {@link GsonBuilder#generateNonExecutableJson()}
+ * - {@link GsonBuilder#serializeNulls()}
+ * - {@link GsonBuilder#setLenient()}
+ * - {@link GsonBuilder#setPrettyPrinting()}
+ *
*/
public JsonWriter newJsonWriter(Writer writer) throws IOException {
if (generateNonExecutableJson) {
@@ -765,12 +774,19 @@ public JsonWriter newJsonWriter(Writer writer) throws IOException {
if (prettyPrinting) {
jsonWriter.setIndent(" ");
}
+ jsonWriter.setHtmlSafe(htmlSafe);
+ jsonWriter.setLenient(lenient);
jsonWriter.setSerializeNulls(serializeNulls);
return jsonWriter;
}
/**
* Returns a new JSON reader configured for the settings on this Gson instance.
+ *
+ * The following settings are considered:
+ *
+ * - {@link GsonBuilder#setLenient()}
+ *
*/
public JsonReader newJsonReader(Reader reader) {
JsonReader jsonReader = new JsonReader(reader);
diff --git a/gson/src/test/java/com/google/gson/GsonTest.java b/gson/src/test/java/com/google/gson/GsonTest.java
index d537f7ad5b..5276371e88 100644
--- a/gson/src/test/java/com/google/gson/GsonTest.java
+++ b/gson/src/test/java/com/google/gson/GsonTest.java
@@ -19,7 +19,10 @@
import com.google.gson.internal.Excluder;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
+import com.google.gson.stream.MalformedJsonException;
import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.text.DateFormat;
@@ -82,4 +85,71 @@ private static final class TestTypeAdapter extends TypeAdapter