[mdr-users] NullPointerException with IBM JRE
"Mike Martin" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.user |
|---|---|
| Organization | NEON Enterprise Systems |
| Message-ID | <[email protected]> |
(I tried filing a bug report on this but it seems my
login doesn't have the necessary permission to do so.)
Running under the IBM JRE produces a NullPointerException
while trying to initialize a B-tree repository.
[java] [org.netbeans.mdr.Logger] Rebooting storage. Reason:
org.netbeans.mdr.persistence.StorageBadRequestException: Btree repository
mdr does not exist
[java] *********** Exception occurred ************ at Wed May 18
15:11:12 CDT 2005
[java] org.netbeans.mdr.util.DebugException: Fatal error: Repository
boot/initialization failed with message: java.lang.NullPointerException:
null
[java] at
org.netbeans.mdr.NBMDRepositoryImpl.initCheck(NBMDRepositoryImpl.java:753)
[java] at
org.netbeans.mdr.NBMDRepositoryImpl.getExtent(NBMDRepositoryImpl.java:298)
[java] at org.netbeans.lib.jmi.uml2mof.Main.init(Main.java:70)
[java] at org.netbeans.lib.jmi.uml2mof.Main.main(Main.java:53)
[java] ANNOTATIONS:
[java] [null] Exception occurred:
This is with latest sources as of today (May 18 2005)
running on an IBM 1.4.1 JRE for z/OS:
$ java -version
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1)
Classic VM (build 1.4.1, J2RE 1.4.1 IBM z/OS Persistent Reusable VM
build cm1411sr2a-20040515 (JIT enabled: jitc))
That's right, I'm running MDR on a mainframe!
I chased the problem and it's failing because some code
in MDRCache is using Map.Entry objects after they've gone
invalid. The following patch fixes it:
Index:
mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/MDRCache.java
===================================================================
RCS file:
/cvs/mdr/src/org/netbeans/mdr/persistence/btreeimpl/btreestorage/MDRCache.java,v
retrieving revision 1.16
diff -r1.16 MDRCache.java
455c455
< result.addAll(newOnes.entrySet());
---
> result.addAll(new HashMap(newOnes).entrySet());
464c464
< ArrayList result = new ArrayList(dirty.entrySet());
---
> ArrayList result = new ArrayList(new
HashMap(dirty).entrySet());
This program demonstrates the difference between the Sun and IBM
JREs re. Map views:
import java.util.*;
public class MapViews
{
public static void main(String[] args)
{
Map m = new HashMap();
m.put("key1", "value1");
m.put("key2", "value2");
Set s = new HashSet(m.entrySet());
m.clear();
System.out.println("Set s = " + s);
}
}
With the Sun JRE this code outputs:
Set s = [key2=value2, key1=value1]
while the IBM JRE outputs:
Set s = [null=null, null=null]
Both are legal results. The IBM version makes it clearer
that Map.Entry objects are valid only for the duration of
an iteration over the entrySet().
Mike