On 07/23/2012 04:31 AM, Claudio Bley wrote:
> When libvirt returns an error code which is not mapped in enum
> ErrorNumber, an IndexOutOfBoundsException is thrown.
>
> I realize that the freshly released libvirt-java 0.4.8 supports all
> error codes up to libvirt 0.9.12. But that doesn't fix the problem.
>
> Would it be feasible to add a special UNKNOWN enum value?
I think that might be better, after all. With your patch...
public Error(virError vError) {
- code = ErrorNumber.values()[vError.code];
- domain = ErrorDomain.values()[vError.domain];
- level = ErrorLevel.values()[vError.level];
+ if (ErrorNumber.values().length > vError.code)
+ code = ErrorNumber.values()[vError.code];
the old version crashed, and your version leaves code as null (which is
a strict improvement, but might cause its own NullPointer issue later
on). Having an else branch that sticks in a placeholder would be nicer
to end clients to at least recognize that they are talking to a newer
server, without crashing.
--
Eric Blake eblake(a)redhat.com +1-919-301-3266
Libvirt virtualization library
http://libvirt.org