Index: modules/beans/src/main/java/java/beans/PropertyEditorManager.java =================================================================== --- modules/beans/src/main/java/java/beans/PropertyEditorManager.java.orig 2006-03-21 07:48:18.000000000 +0000 +++ modules/beans/src/main/java/java/beans/PropertyEditorManager.java 2006-03-27 19:56:11.000000000 +0100 @@ -41,16 +41,17 @@ * @com.intel.drl.spec_ref */ public static void registerEditor(Class targetType, Class editorClass) { - if (targetType != null) { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } - if (editorClass != null) { - registeredEditors.put(targetType, editorClass); - } else { - registeredEditors.remove(targetType); - } + if (targetType == null) + throw new NullPointerException(); + + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPropertiesAccess(); + } + if (editorClass != null) { + registeredEditors.put(targetType, editorClass); + } else { + registeredEditors.remove(targetType); } } @@ -61,48 +62,49 @@ Class editorClass = null; PropertyEditor editor = null; - if (targetType != null) { - editorClass = (Class) registeredEditors.get(targetType); + if (targetType == null) + throw new NullPointerException(); + + editorClass = (Class) registeredEditors.get(targetType); - if (editorClass == null) { - String editorClassName = targetType.getName() + "Editor"; + if (editorClass == null) { + String editorClassName = targetType.getName() + "Editor"; - try { - editorClass = Class.forName( - editorClassName, true, targetType.getClassLoader()); - } catch (ClassNotFoundException cnfe) { - String shortEditorClassName = editorClassName.substring( - editorClassName.lastIndexOf(".") + 1); + try { + editorClass = Class.forName( + editorClassName, true, targetType.getClassLoader()); + } catch (ClassNotFoundException cnfe) { + String shortEditorClassName = editorClassName.substring( + editorClassName.lastIndexOf(".") + 1); - if(targetType.isPrimitive()) { - shortEditorClassName = - shortEditorClassName.substring(0,1).toUpperCase() - + shortEditorClassName.substring(1); - } + if(targetType.isPrimitive()) { + shortEditorClassName = + shortEditorClassName.substring(0,1).toUpperCase() + + shortEditorClassName.substring(1); + } - for (int i = 0; i < path.length; ++i) { - editorClassName = path[i] + "." + shortEditorClassName; + for (int i = 0; i < path.length; ++i) { + editorClassName = path[i] + "." + shortEditorClassName; - try { - editorClass = Class.forName(editorClassName, true, - targetType.getClassLoader()); - } catch (ClassNotFoundException cnfe2) { - } catch (Exception e) { - break; - } + try { + editorClass = Class.forName(editorClassName, true, + targetType.getClassLoader()); + } catch (ClassNotFoundException cnfe2) { + } catch (Exception e) { + break; } - } catch (Exception e) { } + } catch (Exception e) { } + } - if (editorClass != null) { - try { - editor = (PropertyEditor) editorClass.newInstance(); - } catch (Exception e) { - } + if (editorClass != null) { + try { + editor = (PropertyEditor) editorClass.newInstance(); + } catch (Exception e) { } - } + return editor; } Index: modules/beans/src/test/java/org/apache/harmony/tests/beans/PropertyEditorManagerTest.java =================================================================== --- modules/beans/src/test/java/org/apache/harmony/tests/beans/PropertyEditorManagerTest.java.orig 2006-03-21 07:48:16.000000000 +0000 +++ modules/beans/src/test/java/org/apache/harmony/tests/beans/PropertyEditorManagerTest.java 2006-03-27 19:55:46.000000000 +0100 @@ -99,6 +99,24 @@ } } + public void testFindEditor_NPE() { + try { + PropertyEditor pe = + PropertyEditorManager.findEditor((java.lang.Class)null); + fail("findEditor(null) should throw NullPointerException"); + } catch (Exception e) { + } + } + + public void testRegisterEditor_NPE() { + try { + PropertyEditorManager.registerEditor((java.lang.Class)null, + (java.lang.Class)null); + fail("registerEditor(null,null) should throw NullPointerException"); + } catch (Exception e) { + } + } + /** * */