JDK-8199912 - jshell /open URL

Robert Field robert.field at oracle.com
Fri Apr 27 19:45:46 UTC 2018


Thank you Michal and Christian!

I'll take it from here (with the runFile fix rolled in).

-Robert


On 04/27/18 12:10, Christian Stein wrote:
> Looks good to me.
>
> On Thu, Apr 26, 2018 at 3:23 PM Michal Vala <mvala at redhat.com> wrote:
>
>> Hi Christian,
>>
>> thanks for comments.
>> Updated webrev:
>> https://michalvala.fedorapeople.org/webrevs/JDK-8199912/webrev.01/
>>
>> I replaced http request with passing proper source to Scanner. The order
>> of if
>> condition is by probability of the hit. I'm assuming that simple local
>> file path
>> is the most common option, then resource as it's used at the start of the
>> jshell
>> and is cheaper than url request, which is last.
>>
>> I've added also few testcases.
>>
>> Thoughts?
>>
>> On 04/26/2018 09:31 AM, Christian Stein wrote:
>>> Hi Michal,
>>>
>>> 1] I hope so! :)
>>>
>>> 2] Would a simple `java.nio.Files.copy()` using
>>> `java.net.URL`/`openStream()` suffice?
>>>
>>>     try (var stream = new URL(fileUrl).openStream()) {
>>>       Files.copy(stream, target);
>>>     }
>>>
>>> Or a `stream.transferTo(target)` where `target` is piped into the
>> `Scanner`
>>> instance.
>>> This would by-pass the dependency to `java.net.http`.
>>>
>>> 3] Mh, try to create a URI/URL and catch `URISyntaxException` and
>> friends?
>>> 4] When using the `URL.openStream` + `transferTo` methods all http
>> responses
>>> are encapsulated in `IOExceptions`.
>>>
>>> While typing this response, one could refactor the existing
>> `runFile(...)`
>>> method
>>> to only support URIs, local files are just a special case using the
>>> `file://` protocol.
>>>
>>> Cheers,
>>> Christian
>>>
>>>
>>>
>>> On Thu, Apr 26, 2018 at 9:01 AM, Michal Vala <mvala at redhat.com> wrote:
>>>
>>>> Hi,
>>>> I've been implementing jshell function to open scripts from url -
>>>> JDK-8199912.
>>>>
>>>> Here's the rough working implementation: https://michalvala.fedorapeopl
>>>> e.org/webrevs/JDK-8199912/webrev.00/
>>>>
>>>> Few questions:
>>>>
>>>> 1] Is this requirement still valid?
>>>> 2] Is dependency on java.net.http module ok?
>>>> 3] Is there any better way how to detect http URL? This is ugly, but I
>>>> haven't find any better example inside jdk.
>>>> 4] Any better way how to handle http response status?
>>>>
>>>>
>>>>
>>>> --
>>>> Michal Vala
>>>> OpenJDK QE
>>>> Red Hat Czech
>>>>
>> --
>> Michal Vala
>> OpenJDK QE
>> Red Hat Czech
>>



More information about the kulla-dev mailing list