1. You are not checking whether 'tables' is null.

I think the condition check should be in following order :
if (tables != null && tables.length > 0 && tables[0] != null)

2.  Can you please add a regression test for this fix?

Regards,
Ajit

From: Shashidhara Veerabhadraiah 
Sent: Tuesday, June 27, 2017 2:56 PM
To: [email protected]; Philip Race; Sergey Bylokhov
Subject: <Swing Dev> [10] JDK-6919529: NPE from MultiUIDefaults.getUIError

Hi All,
       Please review the fix for the JDK-6919529 where there is a NPE at 
MultiUIDefaults.

Issue: NPE at MultiUIDefaults overridden method of getUIError(String) which 
does not initializes the tables[0] object. There are 2 ways to initialize the 
tables[0] object either via the default constructor or parametric constructor. 
Since the method that is being overridden has the signature of 
getUIError(String), there is no way it can accept the UIDefault instance as an 
input but the code assumes that the default 'UIDefaults' instance be the one 
that is local to the MultiUIDefaults class and assumes that the object is fully 
constructed and hence defaults to the tables[] usage as the default behavior to 
get the UI error.

Resolution: The default assumption that the class instance is fully constructed 
is checked for it's completeness before it's usage. All the other methods 
including overridden methods checks the tables[] is null or not whereas only 
the getUIError() methods does not. This is fixed in this fix.

Test outputs: No NPE at the end of this fix.

Bug: https://bugs.openjdk.java.net/browse/JDK-6919529
Webrev: http://cr.openjdk.java.net/~pkbalakr/shashi/6919529/webrev_00/

Thanks and regards,
Shashi

Reply via email to