Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/java/spark/ExceptionMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ExceptionMapper {

Expand Down Expand Up @@ -52,7 +53,7 @@ public synchronized static ExceptionMapper getServletInstance() {
* Class constructor
*/
public ExceptionMapper() {
this.exceptionMap = new HashMap<>();
this.exceptionMap = new ConcurrentHashMap<>();
}

/**
Expand Down Expand Up @@ -94,7 +95,8 @@ public ExceptionHandlerImpl getHandler(Class<? extends Exception> exceptionClass

// No handler found either for the superclasses of the exception class
// We cache the null value to prevent future
this.exceptionMap.put(exceptionClass, null);
// We do not need to cache the null value. comment by lloyd.
// this.exceptionMap.put(exceptionClass, null);
return null;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/spark/http/matching/MatcherFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ public void doFilter(ServletRequest servletRequest,

String httpMethodStr = method.toLowerCase();
String uri = httpRequest.getRequestURI();
if (uri.length() > 1 && uri.endsWith("/"))
uri = uri.substring(0, uri.length() - 1);
String acceptType = httpRequest.getHeader(ACCEPT_TYPE_REQUEST_MIME_HEADER);

Body body = Body.create();
Expand Down Expand Up @@ -133,7 +135,6 @@ public void doFilter(ServletRequest servletRequest,
BeforeFilters.execute(context);
Routes.execute(context);
AfterFilters.execute(context);

} catch (HaltException halt) {

Halt.modify(httpResponse, body, halt);
Expand Down