[libvirt] [libvirt-java] [PATCH 00/15] Refactor error handling

Claudio Bley cbley at av-test.de
Thu Jan 9 10:07:55 UTC 2014

The error handling in libvirt-java is sort of a mess.

Each and every class contains a processError() method which
just forwards to ErrorHandler.processError(jna.Libvirt).

Furthermore, this processError() method is often called unnecessarily
after every libvirt call, although its return code did not indicate an
error at all.

So, this patchset removes the cruft with the added benefit of avoiding
calls into native code when possible.

Patch #1 starts the refactoring. It adds a few helper methods to the
ErrorHandler class which will be removed by patch #15.

Patch #2 to #13 are mostly mechanical, just wrapping calls of any libvirt
function into a call to processError(int) or processError<T>(T).

Patch #14 removes the obsolete processError(Libvirt) method.

Patch #15 cleans up patch #1.

Claudio Bley (15):
  Start refactoring of error handling
  Remove processError from Device class
  Remove processError from Domain class
  Remove processError from DomainSnapshot class
  Remove processError from Interface class
  Remove processError method from Network class
  Remove processError method from NetworkFilter class
  Remove processError method from Secret class
  Remove processError method from StoragePool class
  Remove processError method from StorageVol class
  Remove processError method from Stream class
  Remove processError method from Connect class
  Call processError only when virInitialize signalled an error
  Remove ErrorHandler.processError(Libvirt) method
  fixup! Start refactoring of error handling

 src/main/java/org/libvirt/Connect.java        |  69 +-----
 src/main/java/org/libvirt/Device.java         |  49 ++--
 src/main/java/org/libvirt/Domain.java         | 328 +++++++++-----------------
 src/main/java/org/libvirt/DomainSnapshot.java |  23 +-
 src/main/java/org/libvirt/ErrorHandler.java   |  44 +++-
 src/main/java/org/libvirt/Interface.java      |  43 +---
 src/main/java/org/libvirt/Library.java        |   4 +-
 src/main/java/org/libvirt/Network.java        |  61 ++---
 src/main/java/org/libvirt/NetworkFilter.java  |  43 +---
 src/main/java/org/libvirt/Secret.java         |  61 ++---
 src/main/java/org/libvirt/StoragePool.java    |  95 +++-----
 src/main/java/org/libvirt/StorageVol.java     |  56 ++---
 src/main/java/org/libvirt/Stream.java         |  64 ++---
 13 files changed, 297 insertions(+), 643 deletions(-)


More information about the libvir-list mailing list