playframework / playframework/play1
NPE upon captcha generation using Java 11
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 671
- Avg merge
- 12d 15h
- Merged PRs (30d)
- 1
Description
Description
Play! version: 1.5.3
Java version: openjdk version "11.0.5" 2019-10-15
OS: Ubuntu 18.04.3 LTS
Consider a Play app consisting of a controller that generates a captcha.
Create a test app
play new test
and change the application controller to
package controllers;
import play.mvc.Controller;
import play.libs.Images;
public class Application extends Controller {
public static void index() {
Images.Captcha captcha = Images.captcha();
renderBinary(captcha);
}
}
start play
play run
and open the browser at http://localhost:9000/
Although the captcha is rendered correctly, logs show an NPE being thrown:
09:21:41,358 WARN ~ You're running Play! in DEV mode
09:21:41,418 INFO ~ Listening for HTTP on port 9000 (Waiting a first request to start) ...
~ Server is up and running
09:21:46,206 INFO ~ Application 'test' is now started !
java.lang.NullPointerException
at jj.play.ns.com.jhlabs.image.TransformFilter.imageComplete(TransformFilter.java)
at java.desktop/sun.awt.image.OffScreenImageSource.produce(OffScreenImageSource.java:193)
at java.desktop/sun.awt.image.OffScreenImageSource.addConsumer(OffScreenImageSource.java:66)
at java.desktop/sun.awt.image.OffScreenImageSource.startProduction(OffScreenImageSource.java:80)
at java.desktop/java.awt.image.FilteredImageSource.startProduction(FilteredImageSource.java:184)
at java.desktop/sun.awt.image.ImageRepresentation.startProduction(ImageRepresentation.java:732)
at java.desktop/sun.awt.image.ToolkitImage.addWatcher(ToolkitImage.java:221)
at java.desktop/sun.awt.image.ToolkitImage.getWidth(ToolkitImage.java:110)
at java.desktop/sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3407)
at jj.play.ns.nl.captcha.util.ImageUtil.applyFilter(Unknown Source)
at jj.play.ns.nl.captcha.gimpy.RippleGimpyRenderer.gimp(Unknown Source)
at play.libs.Images$Captcha.check(Images.java:423)
at play.libs.Images$Captcha.read(Images.java:406)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2146)
at org.apache.commons.io.IOUtils.copy(IOUtils.java:2102)
at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2123)
at play.mvc.results.RenderBinary.copyInputStreamAndClose(RenderBinary.java:207)
at play.mvc.results.RenderBinary.renderInputStream(RenderBinary.java:197)
at play.mvc.results.RenderBinary.apply(RenderBinary.java:157)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:201)
at play.server.PlayHandler$NettyInvocation.execute(PlayHandler.java:289)
at play.Invoker$Invocation$1.apply(Invoker.java:319)
at play.Invoker$Invocation$1.apply(Invoker.java:315)
at play.db.jpa.JPA.withTransaction(JPA.java:349)
at play.db.jpa.JPA.withinFilter(JPA.java:238)
at play.db.jpa.JPAPlugin$TransactionalFilter.withinFilter(JPAPlugin.java:306)
at play.Invoker$Invocation.withinFilter(Invoker.java:298)
at play.Invoker$Invocation.run(Invoker.java:315)
at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:266)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
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)
Expected Behavior
Ideally, the captcha would be generated correctly without the NPE being thrown.
Actual Behavior
Every time a captcha is generated, an NPE is thrown.
Reproducible Test Case
The actual behaviour is consistently reproducible by following the above-mentioned steps.
The behaviour is not reproducible when using Java 8 i.e. the captcha is generated and no NPE is thrown.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with play.libs.Images.Captcha, especially Images.java around Captcha.check and Captcha.read, then trace the call into jj.play.ns.com.jhlabs.image.TransformFilter and ImageUtil.applyFilter shown in the stack trace. Reproduce the captcha request on Java 11 and compare it with Java 8. Done means captcha generation completes without the reported NullPointerException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100