Skip to content

Commit

Permalink
ignore non json commands
Browse files Browse the repository at this point in the history
julian committed Feb 2, 2019
1 parent db33eb4 commit 127d70a
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 6 additions & 0 deletions MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.7
Created-By: 1.8.0_191-b12 (Oracle Corporation)
Implementation-Version: 1.11
Built-By: jgregor5

2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

builder=jgregor5
version=1.10
version=1.11
17 changes: 14 additions & 3 deletions src/server/CommandTask.java
Original file line number Diff line number Diff line change
@@ -2,12 +2,14 @@

import commander.ComponentManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.json.JSONException;
import org.json.JSONObject;

/**
@@ -32,10 +34,19 @@ public Void call() throws Exception {

try {
String line;
while ((line = br.readLine()) != null) {
while ((line = br.readLine()) != null) {

JSONObject command;
try {
command = new JSONObject(line);
} catch (JSONException ex) {
// ignore non json commands
break;
}

LOGGER.log(Level.INFO, "command:{0}", command.toString(4));

try {
JSONObject command = new JSONObject(line);
LOGGER.log(Level.INFO, "command:{0}", command.toString(4));
JSONObject result = ComponentManager.getInstance().execute(command);
LOGGER.log(Level.INFO, "response:{0}", result.toString(4));
pw.println(result);

0 comments on commit 127d70a

Please sign in to comment.