Community
Participate
Working Groups
If you create an XMLResource and then try to save it without adding an object to its contents, you will get a BasicEList$BasicIndexOutOfBoundsException. It appears the problem is that in XMLSaveImpl line 592 calls wreiteTopObjects(contents) when contents.size() != 1 which then calls contents.get(0) which throws the exception because contents.size() == 0.
SAX can't parse an empty file so it's good for save to fail one way or another.
In this case, it doesn't make sense to write a header with empty content? If that's the case, it might be nice to have a better exception ... something like: if(contents.isEmpty()) throw new IOException("Cannot save a resource with no contents");
No, an XML resource must have a single root element. For all I know, someone already catches an index out of bounds exception so while I agree that a descriptive message would be a marginal improvement, the current failure is pretty obvious as well. In fact, this is really a smaller problem than the fact that if you have more than one element, only the first is saved and the rest are silently ignored...