[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17246145#comment-17246145 ] Andreas Hager commented on VELOCITY-934: >From my end, yes! > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17246080#comment-17246080 ] Michael Osipov commented on VELOCITY-934: - Can we close this one? > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17232559#comment-17232559 ] Andreas Hager commented on VELOCITY-934: Thank you for the fast replies and the detailed explanation. [~cbrisson] wrapping the context worked perfectly, Velocity is now running concurrently at 500k pages/second :D !https://raw.githubusercontent.com/casid/template-benchmark/ryzen-5950x/results.png! > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17232419#comment-17232419 ] Claude Brisson commented on VELOCITY-934: - The design choices never changed: the engine is threadsafe, but the context isn't. We might expect that contexts become threadsafe when used in a read-only mode, alas it's not the case with the current code. The concurrent modifications that pose a problem here are a mechanism by which directives (`#foreach` in this case) put their own scope (`$foreach`) in the context before rendering and remove it afterwards. I see two workarounds: 1. If the `$foreach` scope is not needed, it's possible to deactivate it using the setting `context.scope_control.foreach = false`. 2. If it is needed (which is the case here), the natural workaround is to use a wrapping context: @Benchmark public String benchmark() { Writer writer = new StringWriter(); template.merge(new VelocityContext(context), writer); return writer.toString(); } Please note that the initial context content will *not* be copied, only wrapped as an inner context in the new one (this is not a copy constructor). My proposal is to add those details to the documentation. > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17232390#comment-17232390 ] Michael Osipov commented on VELOCITY-934: - I did not say that they are not threadsafe per sé, but I would expect that thread safety is documented as such. [~cbrisson], what is your view? I don't know enough about the code to make bold statements. > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17232389#comment-17232389 ] Michael Osipov commented on VELOCITY-934: - I did not say that they are not threadsafe per sé, but I would expect that thread safety is documented as such. [~cbrisson], what is your view? I don't know enough about the code to make bold statements. > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17232388#comment-17232388 ] Andreas Hager commented on VELOCITY-934: Yes the template is used concurrently. It's a performance benchmark and I think the author wanted Velocity render as fast as possible. This is the code the benchmark uses: {code:java} @Setup public void setup() { Properties configuration = new Properties(); configuration.setProperty("resource.loader", "class"); configuration.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); VelocityEngine engine = new VelocityEngine(configuration); context = new VelocityContext(getContext()); template = engine.getTemplate("templates/stocks.velocity.html", "UTF-8"); } @Benchmark public String benchmark() { Writer writer = new StringWriter(); template.merge(context, writer); return writer.toString(); } {code} So Template and Context are not thread safe? Seems like a strange design decision, since the engine provides those to the caller. Anyways, I could probably change the code to something like this: {code:java} @Benchmark public String benchmark() { context = new VelocityContext(getContext()); template = engine.getTemplate("templates/stocks.velocity.html", "UTF-8"); Writer writer = new StringWriter(); template.merge(context, writer); return writer.toString(); } {code} But I think this would let velocity perform poorly in the benchmark. Is there another thread safe way to do this, while still rendering quickly? > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005)
[jira] [Commented] (VELOCITY-934) NullPointerException under high concurrency
[ https://issues.apache.org/jira/browse/VELOCITY-934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17232383#comment-17232383 ] Michael Osipov commented on VELOCITY-934: - Is the template used concurrently? Unfortunately, none of the classes are documented to be threadsafe. > NullPointerException under high concurrency > --- > > Key: VELOCITY-934 > URL: https://issues.apache.org/jira/browse/VELOCITY-934 > Project: Velocity > Issue Type: Bug > Components: Engine >Affects Versions: 1.7.x, 2.2 > Environment: Windows 10 Professional >Reporter: Andreas Hager >Priority: Major > > I adjusted the mboseke/template-benchmark to profile throughput on AMD Ryzen > 5950x: > [https://github.com/casid/template-benchmark/tree/ryzen-5950x] > With 32 concurrent threads, I can reliably reproduce a runtime exception in > the Apache Velocity benchmark: > {code:java} > java.lang.NullPointerException > at > org.apache.velocity.runtime.directive.Directive.postRender(Directive.java:240) > at > org.apache.velocity.runtime.directive.Foreach.clean(Foreach.java:325) > at > org.apache.velocity.runtime.directive.Foreach.render(Foreach.java:292) > at > org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:301) > at > org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:423) > at org.apache.velocity.Template.merge(Template.java:358) > at org.apache.velocity.Template.merge(Template.java:262) > at com.mitchellbosecke.benchmark.Velocity.benchmark(Velocity.java:34) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_thrpt_jmhStub(Velocity_benchmark_jmhTest.java:122) > at > com.mitchellbosecke.benchmark.generated.Velocity_benchmark_jmhTest.benchmark_Throughput(Velocity_benchmark_jmhTest.java:69) > at jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown > Source) > at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.base/java.lang.reflect.Method.invoke(Method.java:566) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:430) > at > org.openjdk.jmh.runner.BenchmarkHandler$BenchmarkTask.call(BenchmarkHandler.java:412) > at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) > at > java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) > at > java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) > at java.base/java.lang.Thread.run(Thread.java:834) > {code} > This initially happened with version 1.7, but after updating to 2.2 the > problem is still there. It looks like there is some threading issue under > high concurrency. > This is the velocity benchmark class: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/java/com/mitchellbosecke/benchmark/Velocity.java] > And this is the velocity template: > [https://github.com/casid/template-benchmark/blob/ryzen-5950x/src/main/resources/templates/stocks.velocity.html] > > > > -- This message was sent by Atlassian Jira (v8.3.4#803005) - To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org For additional commands, e-mail: dev-h...@velocity.apache.org