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);
Logged In: YES
user_id=506885
Originator: NO
Hello Kordzik,
I can confirm you problem. I have added a test case accordingly to the sourcecode, as you can see here: https://sourceforge.net/mailarchive/message.php?msg_name=E1ICNgK-0003V3-7g%40mail.sourceforge.net . I assume that you agree with that.
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)