Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#142 Topic.createTopicName(...) throws NullPointerException

open
nobody
5
2007-07-08
2007-07-08
Kordzik
No

This refers to release 0.9.8, in-memory implementation (although I doubt it has influence on the bug).

I use TMAPI interface. If it is attempted to create a TopicName with exactly the same value as previously removed TopicName (using Topic.createTopicName(String, Collection)), a RuntimeException is thrown, which is initiated by a NullPointerException.

As far as I could infer, it has something to do with internal events that notify listeners (indexes probably?) that new name was created.

The relevant part of the exception stack:

Exception in thread "main" java.lang.RuntimeException: java.lang.NullPointerException
at org.tm4j.tmapi.core.TMAPITopicImpl.createTopicName(TMAPITopicImpl.java:78)

Example code to replicate the bug:

//assumed TopicMap tm is instantianated beforehand

//creating new user topic
Topic type = tm.createTopic();
Topic t = tm.createTopic();

// creating scope collection
Vector<Topic> scope = new Vector<Topic>();
scope.add(type);

// creating name t.createTopicName("name", scope);

//removing topic
t.remove();

//creating new one
t = tm.createTopic();

//RuntimeException occurs at the following line
t.createTopicName("name", scope);

Discussion

  • Kordzik
    Kordzik
    2007-07-22

    Logged In: YES
    user_id=1830063
    Originator: YES

    Hello Mediumnet,

    Thank you for your response. I agree with the submitted code. Not sure about one thing only - if:
    "catch (TMAPIException ex) {
    fail("Unexpected exception: " + ex.toString());
    }"

    will acutally catch the "bug" exception, since as far as I remember, a RuntimeException is thrown in this case. Or was it intented not to catch it? In the end, the test will fail anyway:) (as error, not failure)