JDK-8199912 - jshell /open URL
Michal Vala
mvala at redhat.com
Sat Apr 28 03:17:59 UTC 2018
Thanks Robert.
Do you mean this one
http://mail.openjdk.java.net/pipermail/kulla-dev/2018-April/002268.html ?
I thought it should go separately under new bug id. Once JDK-8199912 is pushed,
I'll update the other one, because there will be line mismatch.
Anyway, I would like to ask for sponsorship.
On 04/27/2018 09:45 PM, Robert Field wrote:
> 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
>>>
>
--
Michal Vala
OpenJDK QE
Red Hat Czech
More information about the kulla-dev
mailing list