Skip to content

Commit 1cd5a79

Browse files
authored
Simplified the code
1 parent 7caa42d commit 1cd5a79

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/tinystruct/examples/smalltalk.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,18 @@ public String update() throws ApplicationException, IOException {
211211
}
212212

213213
public String update(String meetingCode, String sessionId) throws ApplicationException, IOException {
214+
String error = "{ \"error\": \"expired\" }";
214215
if (this.meetings.containsKey(meetingCode)) {
215216
if(sessions.get(meetingCode) != null && sessions.get(meetingCode).contains(sessionId)) {
216217
return this.update(sessionId);
217218
}
218-
final HttpServletResponse response = (HttpServletResponse) this.context.getAttribute("HTTP_RESPONSE");
219-
response.setContentType("application/json");
220-
response.setStatus(403);
221-
return "{ \"error\": \"session-timeout\" }";
219+
error = "{ \"error\": \"session-timeout\" }";
222220
}
223-
221+
224222
final HttpServletResponse response = (HttpServletResponse) this.context.getAttribute("HTTP_RESPONSE");
225223
response.setContentType("application/json");
226224
response.setStatus(403);
227-
return "{ \"error\": \"expired\" }";
225+
return error;
228226
}
229227

230228
public String upload() throws ApplicationException {
@@ -329,19 +327,19 @@ public void sessionDestroyed(HttpSessionEvent arg0) {
329327
builder.put("time", format.format(new Date()));
330328
builder.put("cmd", "expired");
331329
this.save(meetingCode, builder);
332-
330+
333331
Queue<Builder> messages;
334332
List<String> session_ids;
335-
synchronized (meetings) {
333+
synchronized (this.meetings) {
336334
if((session_ids = this.sessions.get(meetingCode)) != null) {
337335
session_ids.remove(arg0.getSession().getId());
338336
}
339-
340-
if ((messages = meetings.get(meetingCode)) != null) {
337+
338+
if ((messages = this.meetings.get(meetingCode)) != null) {
341339
messages.remove(meetingCode);
342340
}
343-
344-
meetings.notifyAll();
341+
342+
this.meetings.notifyAll();
345343
}
346344

347345
synchronized (this.list) {

0 commit comments

Comments
 (0)