Skip to content

Commit 61bb60e

Browse files
committed
Removing excessive synchronization
1 parent ef68cdf commit 61bb60e

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
@@ -2191,13 +2191,11 @@ public Object optQuery(JSONPointer jsonPointer) {
21912191
@SuppressWarnings("resource")
21922192
public static String quote(String string) {
21932193
StringWriter sw = new StringWriter();
2194-
synchronized (sw.getBuffer()) {
2195-
try {
2196-
return quote(string, sw).toString();
2197-
} catch (IOException ignored) {
2198-
// will never happen - we are writing to a string writer
2199-
return "";
2200-
}
2194+
try {
2195+
return quote(string, sw).toString();
2196+
} catch (IOException ignored) {
2197+
// will never happen - we are writing to a string writer
2198+
return "";
22012199
}
22022200
}
22032201

@@ -2584,9 +2582,7 @@ public String toString() {
25842582
@SuppressWarnings("resource")
25852583
public String toString(int indentFactor) throws JSONException {
25862584
StringWriter w = new StringWriter();
2587-
synchronized (w.getBuffer()) {
2588-
return this.write(w, indentFactor, 0).toString();
2589-
}
2585+
return this.write(w, indentFactor, 0).toString();
25902586
}
25912587

25922588
/**

0 commit comments

Comments
 (0)