[JBoss JIRA] (ARQGRA-461) Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
by Alex Soto (JIRA)
[ https://issues.jboss.org/browse/ARQGRA-461?page=com.atlassian.jira.plugin... ]
Alex Soto commented on ARQGRA-461:
----------------------------------
Well in my case I can run with stream because there is no problem at all. But I have tried to calculate it and I have found this exception and I decided to report it.
Maybe you can close it, but at least if anyone find the same exception in near future, the "solution" is documented somewhere.
> Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: ARQGRA-461
> URL: https://issues.jboss.org/browse/ARQGRA-461
> Project: Arquillian Graphene
> Issue Type: Bug
> Reporter: Alex Soto
> Priority: Minor
> Labels: java8,, threads
>
> Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
> Basically the problem is when you want to get information about tables. You can iterate over elements in a foreach fashion, but you can also use new Java 8 stream API.
> This works: ession.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).stream().map(WebElement::getText).collect(Collectors.toList());
> But if table is big you will try to improve parsing speed by adding parallelSteam (session.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).parallelStream().map(WebElement::getText).collect(Collectors.toList());)
> And in this case an exception is thrown.
> Internally parallelStream uses a pool of threads so probably Graphene instance is tight to thread of test case, so the threads used by parallelStream does not contains a valid instance of Graphene.
> Of course this is not blocking nor a big problem in the sense that you can use stream() without any problem, and moreover Java 8 is not spread yet, but it may be a problem in the future.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 3 months
[JBoss JIRA] (ARQGRA-461) Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
by Lukáš Fryč (JIRA)
[ https://issues.jboss.org/browse/ARQGRA-461?page=com.atlassian.jira.plugin... ]
Lukáš Fryč commented on ARQGRA-461:
-----------------------------------
Hey Alex, this behavior is expectable as {{parallelStream()}} causes the collection to evaluate outside of parental thread.
You will end up with same issues for lot of Arquillian extensions.
----
In fact I think you won't get much gain with {{parallelStream()}} since the Selenium itself is likely serializing requests.
*Idea:* In order to speed up bulk operations, you can use JavaScript-based retrieval logic (JavaScript can return JSON of table structure that you can parse on server-side).
> Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: ARQGRA-461
> URL: https://issues.jboss.org/browse/ARQGRA-461
> Project: Arquillian Graphene
> Issue Type: Bug
> Reporter: Alex Soto
> Priority: Minor
> Labels: java8,, threads
>
> Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
> Basically the problem is when you want to get information about tables. You can iterate over elements in a foreach fashion, but you can also use new Java 8 stream API.
> This works: ession.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).stream().map(WebElement::getText).collect(Collectors.toList());
> But if table is big you will try to improve parsing speed by adding parallelSteam (session.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).parallelStream().map(WebElement::getText).collect(Collectors.toList());)
> And in this case an exception is thrown.
> Internally parallelStream uses a pool of threads so probably Graphene instance is tight to thread of test case, so the threads used by parallelStream does not contains a valid instance of Graphene.
> Of course this is not blocking nor a big problem in the sense that you can use stream() without any problem, and moreover Java 8 is not spread yet, but it may be a problem in the future.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 3 months
[JBoss JIRA] (ARQGRA-461) Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
by Alex Soto (JIRA)
[ https://issues.jboss.org/browse/ARQGRA-461?page=com.atlassian.jira.plugin... ]
Alex Soto updated ARQGRA-461:
-----------------------------
Description:
Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
Basically the problem is when you want to get information about tables. You can iterate over elements in a foreach fashion, but you can also use new Java 8 stream API.
This works: ession.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).stream().map(WebElement::getText).collect(Collectors.toList());
But if table is big you will try to improve parsing speed by adding parallelSteam (session.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).parallelStream().map(WebElement::getText).collect(Collectors.toList());)
And in this case an exception is thrown.
Internally parallelStream uses a pool of threads so probably Graphene instance is tight to thread of test case, so the threads used by parallelStream does not contains a valid instance of Graphene.
Of course this is not blocking nor a big problem in the sense that you can use stream() without any problem, and moreover Java 8 is not spread yet, but it may be a problem in the future.
Steps to Reproduce: Create a Graphene Page object which uses a WebElement inside a parallelStream.
Labels: java8, threads (was: )
Workaround Description: Although you cannot use parallelStream() you can use stream() method.
Workaround: Workaround Exists
> Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
> -------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: ARQGRA-461
> URL: https://issues.jboss.org/browse/ARQGRA-461
> Project: Arquillian Graphene
> Issue Type: Bug
> Reporter: Alex Soto
> Priority: Minor
> Labels: java8,, threads
>
> Running Graphene tests and use parallelStream method makes test fail with java.lang.IllegalStateException: The Graphene runtime isn't initialized. Exception.
> Basically the problem is when you want to get information about tables. You can iterate over elements in a foreach fashion, but you can also use new Java 8 stream API.
> This works: ession.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).stream().map(WebElement::getText).collect(Collectors.toList());
> But if table is big you will try to improve parsing speed by adding parallelSteam (session.findElements(xpath("//table/tbody/tr/td/span[@class='title']")).parallelStream().map(WebElement::getText).collect(Collectors.toList());)
> And in this case an exception is thrown.
> Internally parallelStream uses a pool of threads so probably Graphene instance is tight to thread of test case, so the threads used by parallelStream does not contains a valid instance of Graphene.
> Of course this is not blocking nor a big problem in the sense that you can use stream() without any problem, and moreover Java 8 is not spread yet, but it may be a problem in the future.
--
This message was sent by Atlassian JIRA
(v6.3.1#6329)
10 years, 3 months