File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
commons-core/src/main/scala/com/avsystem/commons
commons-jetty/src/main/scala/com/avsystem/commons/jetty/rest Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,12 @@ object SharedExtensions extends SharedExtensions {
187187 private val RemovableLineBreak = " \\ n+" .r
188188
189189 class StringOps (private val str : String ) extends AnyVal {
190+ /**
191+ * Makes sure that `String` value is not `null` by replacing `null` with empty string.
192+ */
193+ def orEmpty : String =
194+ if (str == null ) " " else str
195+
190196 def ensureSuffix (suffix : String ): String =
191197 if (str.endsWith(suffix)) str else str + suffix
192198
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ object RestServlet {
2727
2828 def readParameters (request : HttpServletRequest ): RestParameters = {
2929 // can't use request.getPathInfo because it decodes the URL before we can split it
30- val pathPrefix = request.getContextPath.opt.getOrElse( " " ) + request.getServletPath.opt.getOrElse( " " )
30+ val pathPrefix = request.getContextPath.orEmpty + request.getServletPath.orEmpty
3131 val path = PathValue .splitDecode(request.getRequestURI.stripPrefix(pathPrefix))
3232 val query = request.getQueryString.opt.map(QueryValue .decode).getOrElse(Mapping .empty)
3333 val headersBuilder = Mapping .newBuilder[HeaderValue ]
You can’t perform that action at this time.
0 commit comments