dazzling-sky / COMP4111-project

COMP4111 project - RESTful Web Service for Library Book Management
https://course.cse.ust.hk/comp4111/project.html
0 stars 0 forks source link

Server fails to respond when no token is provided #16

Open Derppening opened 4 years ago

Derppening commented 4 years ago

Issue description

Submitting a token-less request to any path requiring a token will cause an error in the server.

Steps to reproduce this issue

Assuming the database is setup according to the README and web server is running:

  1. Without executing any request, issue any request to a path requiring a token, but do not provide the token in the request (e.g. http://localhost:8081/BookManagementService/books).

What's the expected result?

What's the actual result?

curl -v -X GET http://localhost:8081/BookManagementService/books
Note: Unnecessary use of -X or --request, GET is already inferred.
*   Trying ::1:8081...
* Connected to localhost (::1) port 8081 (#0)
> GET /BookManagementService/books HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.70.0
> Accept: */*
> 
* Empty reply from server
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server
java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
    at LibraryManagementService_Async.Utils.URIparser.getQueryParams(URIparser.java:62)
    at LibraryManagementService_Async.Utils.URIparser.getToken(URIparser.java:74)
    at LibraryManagementService_Async.Operations.BookManagement.lookBooks(BookManagement.java:99)
    at LibraryManagementService_Async.Handlers.POSTHandler.handleInternal(POSTHandler.java:66)
    at LibraryManagementService_Async.Handlers.Handler.handle(Handler.java:35)
    at LibraryManagementService_Async.Handlers.Handler.handle(Handler.java:13)
    at org.apache.http.nio.protocol.HttpAsyncService.responseReady(HttpAsyncService.java:480)
    at org.apache.http.impl.nio.DefaultNHttpServerConnection.produceOutput(DefaultNHttpServerConnection.java:306)
    at org.apache.http.impl.nio.DefaultHttpServerIODispatch.onOutputReady(DefaultHttpServerIODispatch.java:248)
    at org.apache.http.impl.nio.DefaultHttpServerIODispatch.onOutputReady(DefaultHttpServerIODispatch.java:57)
    at org.apache.http.impl.nio.reactor.AbstractIODispatch.outputReady(AbstractIODispatch.java:145)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.writable(BaseIOReactor.java:187)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:341)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:315)
    at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:276)
    at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:104)
    at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:591)
    at java.base/java.lang.Thread.run(Thread.java:834)

Which part of the spec does this violate?

None, although the following marking scheme point may be of relevance:

  1. The system cannot crash under any testing request.
comp4111ta commented 4 years ago

unhandled exceptions crash the server