[MAGNOLIA-6587] ResourceLinker is not parallelizable Created: 08/Mar/16  Updated: 17/Mar/21  Resolved: 17/Mar/21

Status: Closed
Project: Magnolia
Component/s: None
Affects Version/s: 5.4.3
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Jan Haderka Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled

 Description   

when used within parallel streams like:

collection.parallelStream().forEach(path-> System.out.println(resourceLinker.linkTo(path, cached)));

it will fail with

Caused by: java.lang.NullPointerException
	at info.magnolia.module.resources.ResourceLinker.linkTo(ResourceLinker.java:100)
	at com.neatresults.mgnltweaks.resources.ResourcesTemplatingFunctions$1.lambda$2(ResourcesTemplatingFunctions.java:167)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
	at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
	at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)

Changing parallel stream to sequential all works fine.



 Comments   
Comment by Jan Haderka [ 17/Mar/21 ]

ResourceLinker is still not paralellizable, but at the same time, linear processing of the resources doesn't seem to be causing performance issues to anyone, hence closing the ticket.

Please reopen if a case is identified where this is problematic.

Generated at Mon Feb 12 04:15:55 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.