Avoid NPE in HandlerMappingRegistry (#1763)

diff --git a/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/handler/HandlerMappingRegistry.java b/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/handler/HandlerMappingRegistry.java
index 2d331f9..f1beba8 100644
--- a/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/handler/HandlerMappingRegistry.java
+++ b/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/handler/HandlerMappingRegistry.java
@@ -42,10 +42,8 @@
      * @return A MappingContext if matched, return null if mismatched.
      */
     public Optional<MappingContext<Handler>> getMappingContext(final HttpRequest httpRequest) {
-        UrlPatternMap<Handler> urlPatternMap = mappings.get(httpRequest.method());
         String uriWithoutQuery = httpRequest.uri().split("\\?")[0];
-        return Optional
-                .ofNullable(urlPatternMap.match(uriWithoutQuery));
+        return Optional.ofNullable(mappings.get(httpRequest.method())).map(urlPatternMap -> urlPatternMap.match(uriWithoutQuery));
     }
     
     /**
diff --git a/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/ContextInitializationInboundHandler.java b/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/ContextInitializationInboundHandler.java
index bcd435d..d0459db 100644
--- a/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/ContextInitializationInboundHandler.java
+++ b/elasticjob-infra/elasticjob-restful/src/main/java/org/apache/shardingsphere/elasticjob/restful/pipeline/ContextInitializationInboundHandler.java
@@ -24,6 +24,7 @@
 import io.netty.handler.codec.http.FullHttpRequest;
 import io.netty.handler.codec.http.FullHttpResponse;
 import io.netty.handler.codec.http.HttpResponseStatus;
+import io.netty.handler.codec.http.HttpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.shardingsphere.elasticjob.restful.handler.HandleContext;
 import org.apache.shardingsphere.elasticjob.restful.handler.Handler;
@@ -42,6 +43,7 @@
         log.debug("{}", msg);
         FullHttpRequest httpRequest = (FullHttpRequest) msg;
         FullHttpResponse httpResponse = new DefaultFullHttpResponse(httpRequest.protocolVersion(), HttpResponseStatus.NOT_FOUND, ctx.alloc().buffer());
+        HttpUtil.setContentLength(httpResponse, httpResponse.content().readableBytes());
         ctx.fireChannelRead(new HandleContext<Handler>(httpRequest, httpResponse));
     }
 }