Skip to content

Commit 79af389

Browse files
authored
Merge pull request #774 from mccartney/removing-synchronized
Removing excessive synchronization
2 parents 1726b6c + 61bb60e commit 79af389

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

src/main/java/org/json/JSONArray.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,9 +1646,7 @@ public String toString() {
16461646
@SuppressWarnings("resource")
16471647
public String toString(int indentFactor) throws JSONException {
16481648
StringWriter sw = new StringWriter();
1649-
synchronized (sw.getBuffer()) {
1650-
return this.write(sw, indentFactor, 0).toString();
1651-
}
1649+
return this.write(sw, indentFactor, 0).toString();
16521650
}
16531651

16541652
/**

src/main/java/org/json/JSONObject.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,13 +2183,11 @@ public Object optQuery(JSONPointer jsonPointer) {
21832183
@SuppressWarnings("resource")
21842184
public static String quote(String string) {
21852185
StringWriter sw = new StringWriter();
2186-
synchronized (sw.getBuffer()) {
2187-
try {
2188-
return quote(string, sw).toString();
2189-
} catch (IOException ignored) {
2190-
// will never happen - we are writing to a string writer
2191-
return "";
2192-
}
2186+
try {
2187+
return quote(string, sw).toString();
2188+
} catch (IOException ignored) {
2189+
// will never happen - we are writing to a string writer
2190+
return "";
21932191
}
21942192
}
21952193

@@ -2576,9 +2574,7 @@ public String toString() {
25762574
@SuppressWarnings("resource")
25772575
public String toString(int indentFactor) throws JSONException {
25782576
StringWriter w = new StringWriter();
2579-
synchronized (w.getBuffer()) {
2580-
return this.write(w, indentFactor, 0).toString();
2581-
}
2577+
return this.write(w, indentFactor, 0).toString();
25822578
}
25832579

25842580
/**

0 commit comments

Comments
 (0)