Patch to handle invalid configuration files with -c
If a configuration file is passed to Tigase-Server using -c and the file is not valid XML, a NullPointerException is thrown with the following stack trace:
ThreadExceptionHandler.uncaughtException() SEVERE: Uncaught thread: "main" exceptionjava.lang.NullPointerException
at tigase.xml.db.XMLDB.loadDB(XMLDB.java:175)
at tigase.xml.db.XMLDB.(XMLDB.java:134)
at tigase.conf.ConfigRepository.init(ConfigRepository.java:109)
at tigase.conf.ConfigRepository.(ConfigRepository.java:97)
at tigase.conf.ConfigRepository.getConfigRepository(ConfigRepository.java:89)
at tigase.conf.ConfigRepository.getConfigRepository(ConfigRepository.java:71)
at tigase.conf.Configurator.(Configurator.java:217)
at tigase.server.XMPPServer.main(XMPPServer.java:151)
Since ConfigRepository.getConfigRepository already has error handling for IOExceptions that creates a new database if the specified one cannot be loaded, the NullPointerException that is not caught can be prevented by throwing a IOException.
The patch below fixes thie problem:
Index: XMLDB.java
===================================================================
--- XMLDB.java (revision 395)
+++ XMLDB.java (working copy)
@@ -172,6 +172,8 @@
file.close();
root = (DBElement)domHandler.getParsedElements().poll();
// node1s = root.getChildren();
+ if(root == null)
+ throw new IOException("Invalid XML DB File");
this.root_name = root.getName();
List children = root.getChildren();
if (children != null && children.size() > 0) {
Trackback URL for this post:
- Add new comment
- 1177 reads






hehe, indeed, as you are posting anonymously I had no idea that was you all the time.
Please send me an e-mail to my address: kobit AT tigase.org with your desired user name. I will create an account for you and you will receive email back with activation link.
Good point, I didn't think about it overwriting the file. Thanks for accepting the patch.
Also, since I seem to be posting a lot recently, do you have a registration page for the site so I can stop posting as anonymous? I see the login page but have not been able to find a way to create an account.
-Alan Geleynse
Thank you for the patch.
I have already applied it but instead of throwing IOException I added throwing XMLDBException which cause the server to terminate it and display information to the end user about the problem.
This is because IOException cause to re-create the XML file and it may in turn cause to overwrite existing user file if he put it in the parameters list by mistake.