This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | NullPointerException at org.netbeans.modules.db.explorer.node.SchemaNodeProvider$SchemaComparator.compare | ||
---|---|---|---|
Product: | db | Reporter: | dlttorezan |
Component: | Code | Assignee: | Jiri Rechtacek <jrechtacek> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gtg, hdeantoni, MarcosJava, mirceade, ravilan |
Priority: | P2 | ||
Version: | 7.0 | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | DEFECT | Exception Reporter: | 180811 |
Attachments: |
stacktrace
stacktrace Proposed patch |
Description
dlttorezan
2011-08-27 16:15:21 UTC
Created attachment 110255 [details]
stacktrace
This bug already has 5 duplicates see http://statistics.netbeans.org/exceptions/detail.do?id=180811 Created attachment 111932 [details]
stacktrace
Added more logging to see what went wrong - core-main/rev/f34c77fbbffd This bug already has 20 duplicates see http://statistics.netbeans.org/exceptions/detail.do?id=180811 Created attachment 116099 [details]
Proposed patch
There are code paths, that can lead to null display names - from renderNames in SchemaNode.java (lines 146-153): if (schema == null) { name = ""; } else { name = schema.getName(); } if (name == null) { name = schema.getParent().getName(); } so it needs both the schema Name and the catalog name (this is the parent of the schema) to be null. NULL-Catalogs can be created - from JDBCMetadata.java lines 171: defaultCatalog = createJDBCCatalog(null, true, defaultSchemaName).getCatalog(); And in JDBCCatalog line 173 a JDBCSchema with a null name is created: syntheticSchema = createJDBCSchema(null, _default, true).getSchema(); So the Comparator has to deal with null values I see your point matthias, it will fix this issue, but maybe it would be better to edit renderNames to be sure that "" is returned instead of null. Something like this: if (schema == null) { name = ""; } else { name = schema.getName(); } if (name == null) { name = schema.getParent().getName(); } if (name == null) { name = "" } so you don't have to check "notNull" every time you call node.getDiplayName/getName I'm going to implement this variant but if you have any objections let me know and we can discuss it. *** Bug 207828 has been marked as a duplicate of this bug. *** Go ahead :-) - I don't see a reason not to implement it like that. It's a bit more invasive than changing the comparator, but I seriously hope noone expected null to be a valid name and build logic upon that. Integrated into 'main-golden', will be available in build *201204240400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-golden/rev/f07756987b19 User: Jan Peska <JPESKA@netbeans.org> Log: Issue #201380 - NullPointerException at org.netbeans.modules.db.explorer.node.SchemaNodeProvider$SchemaComparator.compare Make sure that "" will be assigned to the name field instead of null |