Bug 1073906

Summary: java bindings inspect_list_applications2 throws java.lang.ArrayIndexOutOfBoundsException:
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: acathrow, jherrman, kees2006, maarten.fonville, mbooth, ptoscano
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
In the Java binding, or APIs that return a list of objects different from String caused an ArrayIndexOutOfBoundsException exception to be triggered. The creation of the result list has been fixed, and these APIs now return the expected result.
Story Points: ---
Clone Of:
: 1073917 1074005 (view as bug list) Environment:
Last Closed: 2014-03-07 16:04:26 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1073917, 1074005    
Attachments:
Description Flags
InspectVM.java none

Description Richard W.M. Jones 2014-03-07 13:08:47 UTC
Created attachment 871888 [details]
InspectVM.java

Description of problem:

Using the inspect_list_applications2 function causes java.lang.ArrayIndexOutOfBoundsException to be thrown.

Version-Release number of selected component (if applicable):

libguestfs-java-1.25.42-1.fc21.x86_64

How reproducible:

100%

Steps to Reproduce:

Download InspectVM.java file attached.

Compile it like this:

javac -classpath /usr/share/java/libguestfs.jar InspectVM.java 

To test this you will need any Linux disk image.  eg. Build one using
virt-builder:

virt-builder fedora-20

Run the program on this disk image:

$ java -classpath /usr/share/java/libguestfs.jar:. InspectVM fedora-20.img 
Root device: /dev/sda3
  Product name: Fedora release 20 (Heisenbug)
  Version:      20.0
  Type:         linux
  Distro:       fedora
java.lang.ArrayIndexOutOfBoundsException: 231

It shouldn't print the ArrayIndexOutOfBoundsException error.

Comment 1 Maarten 2014-03-07 13:24:57 UTC
This same bug appears with a ubuntu guest machine.

Tewsted it with JDK Oracle 1.8 and multiple  libguestfs versions (up to 1.24.5)

Comment 2 Richard W.M. Jones 2014-03-07 15:29:16 UTC
Patches posted:
https://www.redhat.com/archives/libguestfs/2014-March/thread.html#00042

Comment 3 Richard W.M. Jones 2014-03-07 16:04:26 UTC
I pushed this series upstream, on the basis that:

 - passes make check

 - passes make check-valgrind [but valgrind probably isn't run on
   the java bindings, so this may not be meaningful]

 - should be at least an improvement on the previous situation, even
   if we discover further problems.

Therefore I'm closing this bug, fixed upstream in libguestfs >= 1.25.43.

These are candidates for backporting to the stable branch.

Please reopen if you find further problems with
g.inspect_list_applications2.  For other Java bindings bugs,
open a new bug.

Comment 4 Richard W.M. Jones 2014-03-08 13:24:36 UTC
I've backported the fixes to 1.24.7 which will be released soon.

Comment 5 Richard W.M. Jones 2015-08-04 10:24:05 UTC
*** Bug 1249918 has been marked as a duplicate of this bug. ***