# HG changeset patch # User Jiri Vanek # Date 1411398799 -7200 # Node ID 249435147a0bbf7cb108c321fc5f3866908c4619 # Parent e66c55de3d2204d38b2b38489bcf49c6b0b76eba Preventing rare class cast exception in erroneous detached applets diff -r e66c55de3d22 -r 249435147a0b ChangeLog --- a/ChangeLog Sun Sep 21 10:43:48 2014 -0400 +++ b/ChangeLog Mon Sep 22 17:13:19 2014 +0200 @@ -1,3 +1,13 @@ +2014-09-22 Jiri Vanek + + Preventing rare class cast exception in erroneous detached applets + * netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java: getSplashControler + renamed to getSplashController. (getSplashController) added check for + SplashController instance. Returning null if not so. + * netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java: adapted to renaming + * tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java: + added (assertNulsAreOkInShow) test to check null values for showError methods + 2014-09-21 Andrew Azores * netx/javaws.1: Fixed typos, made formatting more consistent, and added diff -r e66c55de3d22 -r 249435147a0b netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java --- a/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java Sun Sep 21 10:43:48 2014 -0400 +++ b/netx/net/sourceforge/jnlp/runtime/AppletEnvironment.java Mon Sep 22 17:13:19 2014 +0200 @@ -138,9 +138,12 @@ * container must be SplashContoler * */ - public SplashController getSplashControler() { - - return (SplashController)cont; + public SplashController getSplashController() { + if (cont instanceof SplashController) { + return (SplashController) cont; + } else { + return null; + } } /** diff -r e66c55de3d22 -r 249435147a0b netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java --- a/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java Sun Sep 21 10:43:48 2014 -0400 +++ b/netx/net/sourceforge/jnlp/splashscreen/SplashUtils.java Mon Sep 22 17:13:19 2014 +0200 @@ -94,7 +94,7 @@ if (ae == null) { return; } - SplashController p = ae.getSplashControler(); + SplashController p = ae.getSplashController(); showError(ex, p); } diff -r e66c55de3d22 -r 249435147a0b tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java Sun Sep 21 10:43:48 2014 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/splashscreen/SplashUtilsTest.java Mon Sep 22 17:13:19 2014 +0200 @@ -40,6 +40,8 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import net.sourceforge.jnlp.runtime.AppletEnvironment; +import net.sourceforge.jnlp.runtime.AppletInstance; import net.sourceforge.jnlp.runtime.JNLPRuntime; import net.sourceforge.jnlp.splashscreen.impls.*; import org.junit.Assert; @@ -251,5 +253,13 @@ field.setAccessible(true); field.set(null, newValue); } + + @Test + public void assertNulsAreOkInShow() { + SplashUtils.showError(null, (AppletEnvironment)null); + SplashUtils.showError(null, (AppletInstance)null); + SplashUtils.showError(null, (SplashController)null); + } + } diff -r e66c55de3d22 -r 249435147a0b tests/netx/unit/net/sourceforge/jnlp/util/logging/JavaConsoleTest.java --- a/tests/netx/unit/net/sourceforge/jnlp/util/logging/JavaConsoleTest.java Sun Sep 21 10:43:48 2014 -0400 +++ b/tests/netx/unit/net/sourceforge/jnlp/util/logging/JavaConsoleTest.java Mon Sep 22 17:13:19 2014 +0200 @@ -26,7 +26,7 @@ Assert.assertFalse(p3.wasError); Assert.assertTrue(p1.header.isC); Assert.assertTrue(p3.header.isC); - Assert.assertEquals(OutputController.Level.MESSAGE_DEBUG,p1.header.level); + Assert.assertEquals(OutputController.Levgl.MESSAGE_DEBUG,p1.header.level); Assert.assertEquals(OutputController.Level.ERROR_ALL,p3.header.level); Assert.assertTrue(p1.header.date.toString().contains("Tue Nov 19 09:43:50") && p1.header.date.toString().contains("2013")); Assert.assertTrue(p3.header.date.toString().contains("Tue Nov 19 09:43:50") && p3.header.date.toString().contains("2013"));