Skip to content

Commit

Permalink
openvidu-server: fix NullPointer if no shmSize passed to POST /api/re…
Browse files Browse the repository at this point in the history
…cordings/start
  • Loading branch information
pabloFuente committed Jun 17, 2020
1 parent 37c05cb commit 7599107
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,23 @@ public ResponseEntity<?> listSessions(
log.info("REST API: GET /api/sessions?webRtcStats={}", webRtcStats);

Collection<Session> sessions = this.sessionManager.getSessionsWithNotActive();

log.info("1. Session collection retrieved");

JsonObject json = new JsonObject();
JsonArray jsonArray = new JsonArray();
sessions.forEach(s -> {

log.info("2. Gathering info for session {}", s.getSessionId());

JsonObject sessionJson = (webRtcStats == true) ? s.withStatsToJson() : s.toJson();
jsonArray.add(sessionJson);
});
json.addProperty("numberOfElements", sessions.size());
json.add("content", jsonArray);

log.info("3. Sending response back");

return new ResponseEntity<>(json.toString(), getResponseHeaders(), HttpStatus.OK);
}

Expand Down Expand Up @@ -460,7 +469,7 @@ public ResponseEntity<?> startRecordingSession(@RequestBody Map<?, ?> params) {
Boolean hasVideo;
String recordingLayoutString;
String customLayout;
Long shmSize;
Long shmSize = null;
try {
sessionId = (String) params.get("session");
name = (String) params.get("name");
Expand All @@ -470,7 +479,9 @@ public ResponseEntity<?> startRecordingSession(@RequestBody Map<?, ?> params) {
hasVideo = (Boolean) params.get("hasVideo");
recordingLayoutString = (String) params.get("recordingLayout");
customLayout = (String) params.get("customLayout");
shmSize = new Long(params.get("shmSize").toString());
if (params.get("shmSize") != null) {
shmSize = new Long(params.get("shmSize").toString());
}
} catch (ClassCastException | NumberFormatException e) {
return this.generateErrorResponse("Type error in some parameter", "/api/recordings/start",
HttpStatus.BAD_REQUEST);
Expand Down

0 comments on commit 7599107

Please sign in to comment.