@@ -51,8 +51,8 @@ public void run(final int socketNum, final String token) {
51
51
public void run () {
52
52
try {
53
53
runServer (socketNum , token );
54
- } catch (IOException e ) {
55
- log ("startServer failed: " , e );
54
+ } catch (Exception e ) {
55
+ log ("Server failed to start : " , e );
56
56
}
57
57
}
58
58
});
@@ -87,6 +87,7 @@ private void runServer(final int socketNum, final String token) throws IOExcepti
87
87
THREAD_POOL .submit (new Request (socket , token ));
88
88
} catch (Exception e ) {
89
89
log ("Server failed" , e );
90
+ break ;
90
91
}
91
92
}
92
93
}
@@ -321,15 +322,15 @@ public void run() {
321
322
}
322
323
}
323
324
} catch (IOException e ) {
324
- log ("request failed" , e );
325
+ log ("Request failed" , e );
325
326
}
326
327
finally {
327
328
afterRun ();
328
329
}
329
330
}
330
331
331
332
private void afterRun () {
332
- log ("socket cleanup" );
333
+ log ("Socket cleanup" );
333
334
try {
334
335
if (socket != null ) {
335
336
socket .close ();
@@ -338,7 +339,7 @@ private void afterRun() {
338
339
inputStream .close ();
339
340
}
340
341
} catch (IOException e ) {
341
- log ("socket cleanup failed: " , e );
342
+ log ("Socket cleanup failed: " , e );
342
343
}
343
344
}
344
345
@@ -389,7 +390,7 @@ private Response handleDownload(Map<String, Collection<String>> data) throws IOE
389
390
* Handler for files API
390
391
*/
391
392
private Response handleFileList () throws IOException {
392
- log ("sending file list" );
393
+ log ("Sending file list" );
393
394
JsonBuilder builder = new JsonBuilder ();
394
395
builder .append ('[' );
395
396
long id = 0 ;
@@ -433,7 +434,7 @@ private void handlePost(Map<String, String> data) throws IOException {
433
434
if (userToken == null ) {
434
435
userToken = requestToken ;
435
436
}
436
- log ("userToken =" + userToken );
437
+ log ("UserToken =" + userToken );
437
438
if (tokenKey .equals (userToken )) {
438
439
if (url .startsWith ("/api/login" )) {
439
440
handleFileList ().send (socket , userToken );
@@ -532,7 +533,7 @@ private Response handleWebResponse(String asset) throws IOException {
532
533
try {
533
534
result = getFile (path , true );
534
535
} catch (Exception e ) {
535
- log ("error : " + e );
536
+ log ("Error : " + e );
536
537
result = null ;
537
538
}
538
539
return result != null ? result : new Response (SC_NOT_FOUND );
@@ -570,7 +571,7 @@ public Response(int errorCode) throws IOException {
570
571
* Sends the response to the given socket
571
572
*/
572
573
void send (Socket socket , String cookie ) throws IOException {
573
- log ("sendResponse() entered " );
574
+ log ("Sending response " );
574
575
String contentLength = "Content-length: " + length + "\r \n " ;
575
576
BufferedOutputStream out = new BufferedOutputStream (socket .getOutputStream ());
576
577
String code = errorCode == SC_OKAY ? SC_OKAY + " OK" : String .valueOf (errorCode );
@@ -583,7 +584,7 @@ void send(Socket socket, String cookie) throws IOException {
583
584
out .write ("Server: SmallBASIC for Android\r \n \r \n " .getBytes (UTF_8 ));
584
585
socket .setSendBufferSize (SEND_SIZE );
585
586
int sent = toStream (out );
586
- log ("sent " + sent + " bytes" );
587
+ log ("Sent " + sent + " bytes" );
587
588
out .close ();
588
589
}
589
590
0 commit comments