Merge pull request #774 from mccartney/removing-synchronized

Removing excessive synchronization
This commit is contained in:
Sean Leary 2023-10-04 07:40:10 -05:00 committed by GitHub
commit 79af389f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 13 deletions

View File

@ -1646,9 +1646,7 @@ public class JSONArray implements Iterable<Object> {
@SuppressWarnings("resource") @SuppressWarnings("resource")
public String toString(int indentFactor) throws JSONException { public String toString(int indentFactor) throws JSONException {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
synchronized (sw.getBuffer()) { return this.write(sw, indentFactor, 0).toString();
return this.write(sw, indentFactor, 0).toString();
}
} }
/** /**

View File

@ -2183,13 +2183,11 @@ public class JSONObject {
@SuppressWarnings("resource") @SuppressWarnings("resource")
public static String quote(String string) { public static String quote(String string) {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
synchronized (sw.getBuffer()) { try {
try { return quote(string, sw).toString();
return quote(string, sw).toString(); } catch (IOException ignored) {
} catch (IOException ignored) { // will never happen - we are writing to a string writer
// will never happen - we are writing to a string writer return "";
return "";
}
} }
} }
@ -2576,9 +2574,7 @@ public class JSONObject {
@SuppressWarnings("resource") @SuppressWarnings("resource")
public String toString(int indentFactor) throws JSONException { public String toString(int indentFactor) throws JSONException {
StringWriter w = new StringWriter(); StringWriter w = new StringWriter();
synchronized (w.getBuffer()) { return this.write(w, indentFactor, 0).toString();
return this.write(w, indentFactor, 0).toString();
}
} }
/** /**