@@ -51,8 +51,8 @@ public void run(final int socketNum, final String token) {
5151 public void run () {
5252 try {
5353 runServer (socketNum , token );
54- } catch (IOException e ) {
55- log ("startServer failed: " , e );
54+ } catch (Exception e ) {
55+ log ("Server failed to start : " , e );
5656 }
5757 }
5858 });
@@ -87,6 +87,7 @@ private void runServer(final int socketNum, final String token) throws IOExcepti
8787 THREAD_POOL .submit (new Request (socket , token ));
8888 } catch (Exception e ) {
8989 log ("Server failed" , e );
90+ break ;
9091 }
9192 }
9293 }
@@ -321,15 +322,15 @@ public void run() {
321322 }
322323 }
323324 } catch (IOException e ) {
324- log ("request failed" , e );
325+ log ("Request failed" , e );
325326 }
326327 finally {
327328 afterRun ();
328329 }
329330 }
330331
331332 private void afterRun () {
332- log ("socket cleanup" );
333+ log ("Socket cleanup" );
333334 try {
334335 if (socket != null ) {
335336 socket .close ();
@@ -338,7 +339,7 @@ private void afterRun() {
338339 inputStream .close ();
339340 }
340341 } catch (IOException e ) {
341- log ("socket cleanup failed: " , e );
342+ log ("Socket cleanup failed: " , e );
342343 }
343344 }
344345
@@ -389,7 +390,7 @@ private Response handleDownload(Map<String, Collection<String>> data) throws IOE
389390 * Handler for files API
390391 */
391392 private Response handleFileList () throws IOException {
392- log ("sending file list" );
393+ log ("Sending file list" );
393394 JsonBuilder builder = new JsonBuilder ();
394395 builder .append ('[' );
395396 long id = 0 ;
@@ -433,7 +434,7 @@ private void handlePost(Map<String, String> data) throws IOException {
433434 if (userToken == null ) {
434435 userToken = requestToken ;
435436 }
436- log ("userToken =" + userToken );
437+ log ("UserToken =" + userToken );
437438 if (tokenKey .equals (userToken )) {
438439 if (url .startsWith ("/api/login" )) {
439440 handleFileList ().send (socket , userToken );
@@ -532,7 +533,7 @@ private Response handleWebResponse(String asset) throws IOException {
532533 try {
533534 result = getFile (path , true );
534535 } catch (Exception e ) {
535- log ("error : " + e );
536+ log ("Error : " + e );
536537 result = null ;
537538 }
538539 return result != null ? result : new Response (SC_NOT_FOUND );
@@ -570,7 +571,7 @@ public Response(int errorCode) throws IOException {
570571 * Sends the response to the given socket
571572 */
572573 void send (Socket socket , String cookie ) throws IOException {
573- log ("sendResponse() entered " );
574+ log ("Sending response " );
574575 String contentLength = "Content-length: " + length + "\r \n " ;
575576 BufferedOutputStream out = new BufferedOutputStream (socket .getOutputStream ());
576577 String code = errorCode == SC_OKAY ? SC_OKAY + " OK" : String .valueOf (errorCode );
@@ -583,7 +584,7 @@ void send(Socket socket, String cookie) throws IOException {
583584 out .write ("Server: SmallBASIC for Android\r \n \r \n " .getBytes (UTF_8 ));
584585 socket .setSendBufferSize (SEND_SIZE );
585586 int sent = toStream (out );
586- log ("sent " + sent + " bytes" );
587+ log ("Sent " + sent + " bytes" );
587588 out .close ();
588589 }
589590
0 commit comments