File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed
java/server/src/org/openqa/grid/web/servlet Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change 18
18
19
19
package org .openqa .grid .web .servlet ;
20
20
21
+ import com .google .common .io .CharStreams ;
21
22
import com .google .gson .Gson ;
22
23
import com .google .gson .JsonElement ;
23
24
import com .google .gson .JsonObject ;
@@ -147,17 +148,15 @@ private JsonObject getSlotCounts() {
147
148
}
148
149
149
150
private JsonObject getRequestJSON (HttpServletRequest request ) throws IOException {
150
- JsonObject requestJSON = null ;
151
- BufferedReader rd = new BufferedReader (new InputStreamReader (request .getInputStream ()));
152
- StringBuilder s = new StringBuilder ();
153
- String line ;
154
- while ((line = rd .readLine ()) != null ) {
155
- s .append (line );
156
- }
157
- rd .close ();
158
- String json = s .toString ();
159
- if (!"" .equals (json )) {
160
- requestJSON = new JsonParser ().parse (json ).getAsJsonObject ();
151
+ JsonObject requestJSON = new JsonObject ();
152
+
153
+ try (BufferedReader rd = new BufferedReader (new InputStreamReader (request .getInputStream ()))) {
154
+ StringBuilder s = new StringBuilder ();
155
+ CharStreams .copy (rd , s );
156
+ String json = s .toString ();
157
+ if (!"" .equals (json )) {
158
+ requestJSON = new JsonParser ().parse (json ).getAsJsonObject ();
159
+ }
161
160
}
162
161
return requestJSON ;
163
162
}
You can’t perform that action at this time.
0 commit comments