prefer statically-typed close operation, avoid Java 11 warning: "Illegal reflective access by scala.reflect.package$ to method sun.net.httpserver.LeftOverInputStream.close()";
authorwenzelm
Wed Nov 14 21:43:33 2018 +0100 (3 weeks ago)
changeset 693055a71b5145201
parent 69304 1f4afcde3334
child 69306 341ebf35464b
prefer statically-typed close operation, avoid Java 11 warning: "Illegal reflective access by scala.reflect.package$ to method sun.net.httpserver.LeftOverInputStream.close()";
src/Pure/General/http.scala
     1.1 --- a/src/Pure/General/http.scala	Wed Nov 14 21:28:48 2018 +0100
     1.2 +++ b/src/Pure/General/http.scala	Wed Nov 14 21:43:33 2018 +0100
     1.3 @@ -45,13 +45,18 @@
     1.4      def request_uri: URI = http_exchange.getRequestURI
     1.5  
     1.6      def read_request(): Bytes =
     1.7 -      using(http_exchange.getRequestBody)(Bytes.read_stream(_))
     1.8 +    {
     1.9 +      val stream = http_exchange.getRequestBody
    1.10 +      try { Bytes.read_stream(stream) } finally { stream.close }
    1.11 +    }
    1.12  
    1.13      def write_response(code: Int, response: Response)
    1.14      {
    1.15        http_exchange.getResponseHeaders().set("Content-Type", response.content_type)
    1.16        http_exchange.sendResponseHeaders(code, response.bytes.length.toLong)
    1.17 -      using(http_exchange.getResponseBody)(response.bytes.write_stream(_))
    1.18 +
    1.19 +      val stream = http_exchange.getResponseBody
    1.20 +      try { response.bytes.write_stream(stream) } finally { stream.close }
    1.21      }
    1.22    }
    1.23