New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exceptions are not received by the caller #28

Closed
hubertverstraete opened this Issue Feb 2, 2015 · 8 comments

Comments

Projects
None yet
2 participants
@hubertverstraete
Contributor

hubertverstraete commented Feb 2, 2015

Each API call may throw an exception that is defined in the vSphere API reference. But these exceptions are not received by the caller.
I have written a very simple code that tries to login to an ESXi/vCenter server with an unknown user. The expected result is to receive an InvalidLogin exception, but no exception is received.

Until vijava 5.1, I was receiving all exceptions as expected, but in vijava 5.5 beta I had noticed that one exception was received with another identity. I may have missed the fact that it happens for all exceptions since vijava 5.5 beta and therefore the problem may exist before the fork to yavijava. The difference in yavijava is that I don't receive an exception at all.

Environment on CentOS 7:
Oracle JDK 1.7.0_75
yavijava-5.5.07.jar
httpclient-4.3.5.jar
dom4j-1.6.1.jar
log4j-1.2.17.jar

@hubertverstraete

This comment has been minimized.

Contributor

hubertverstraete commented Feb 2, 2015

import java.net.URL;
import com.vmware.vim25.InvalidLogin;
import com.vmware.vim25.mo.ServiceInstance;

public class do_invalid_login
{
    public static void main(String[] args) throws Exception
    {
        String serverDns = args[0];
        String login = "unknown_user";
        String passwd = "password";
        ServiceInstance si = null;

        URL url = new URL("https://" + serverDns + "/sdk");

        try {
            si = new ServiceInstance(url, login, passwd, true);
        }
        catch (InvalidLogin e) {
            System.out.println("Received InvalidLogin exception as expected");
            System.exit(1);
        }
        catch (Exception e) {
            System.out.println("Received another exception: " + e);
            System.exit(1);
        }

        System.out.println("Did not receive an exception. " + si);

        if (si == null) {
            System.out.println("Cannot connect to " + serverDns);
            System.exit(1);
        }

        si.getServerConnection().logout();
    }
}
@michaelrice

This comment has been minimized.

Member

michaelrice commented Feb 2, 2015

Which version of java are you using?

-mike
On Feb 2, 2015 8:51 AM, "hubertverstraete" notifications@github.com
wrote:

Each API call may throw an exception that is defined in the vSphere API
reference. But these exceptions are not received by the caller.
I have written a very simple code that tries to login to an ESXi/vCenter
server with an unknown user. The expected result is to receive an
InvalidLogin exception, but no exception is received.

Until vijava 5.1, I was receiving all exceptions as expected, but in
vijava 5.5 beta I had noticed that one exception was received with another
identity. I may have missed the fact that it happens for all exceptions
since vijava 5.5 beta and therefore the problem may exist before the fork
to yavijava. The difference in yavijava is that I don't receive an
exception at all.


Reply to this email directly or view it on GitHub
https://github.com/michaelrice/yavijava/issues/28.

@hubertverstraete

This comment has been minimized.

Contributor

hubertverstraete commented Feb 2, 2015

I've edited my first comment while you were sending this mail, please
reload the page.

On Mon, Feb 2, 2015 at 3:55 PM, Michael Rice notifications@github.com
wrote:

Which version of java are you using?

-mike
On Feb 2, 2015 8:51 AM, "hubertverstraete" notifications@github.com
wrote:

Each API call may throw an exception that is defined in the vSphere API
reference. But these exceptions are not received by the caller.
I have written a very simple code that tries to login to an ESXi/vCenter
server with an unknown user. The expected result is to receive an
InvalidLogin exception, but no exception is received.

Until vijava 5.1, I was receiving all exceptions as expected, but in
vijava 5.5 beta I had noticed that one exception was received with
another
identity. I may have missed the fact that it happens for all exceptions
since vijava 5.5 beta and therefore the problem may exist before the
fork
to yavijava. The difference in yavijava is that I don't receive an
exception at all.


Reply to this email directly or view it on GitHub
https://github.com/michaelrice/yavijava/issues/28.


Reply to this email directly or view it on GitHub
https://github.com/michaelrice/yavijava/issues/28#issuecomment-72469962.

@michaelrice michaelrice self-assigned this Feb 2, 2015

@michaelrice

This comment has been minimized.

Member

michaelrice commented Feb 2, 2015

I can tell this is going to take some time to fix. There are literally 0 tests around this part of the code. Im looking into how to test it the way its currently implemented but its looking more and more like Im going to have to do a fair bit of refactoring to make this part of the code testable. Ill keep you updated with what I find and try to get a fix out as quickly as I can.

michaelrice added a commit that referenced this issue Feb 7, 2015

addresses the bug reported in #28
This patch only restores the broken functionality
that the beta release of vijava 5.5 had that would
only throw RemoteExceptions and did not actually
throw underlying exceptions.
@michaelrice

This comment has been minimized.

Member

michaelrice commented Feb 7, 2015

@hubertverstraete I have a small patch that restores the broken exceptions in vijava 5.5 I was doing some testing and found that vijava 5.5 beta is only throwing a RemoteException when it should be throwing something else. The commit 74e438a restores that. I am going to work on fixing the actual problem this weekend. Before I work on fixing it though I am going to start writing tests around the parser. That way the fix will be easier and I can be confident that the fix doesnt break something else.

@michaelrice

This comment has been minimized.

Member

michaelrice commented Feb 20, 2015

Hi @hubertverstraete

My latest commit 1cb9066 fixes the issue you reported. Im not going to rush out an update to maven because I still dont have the test coverage I want and I would like to make sure there arent any other issues like this, but please apply the patch and do some tests and let me know how it goes.

@hubertverstraete

This comment has been minimized.

Contributor

hubertverstraete commented Feb 20, 2015

Hi Michael,
I've tried with the latest commit and for now it works much much better.
I was able to receive the following exceptions and their arguments:
InvalidPowerState
GuestOperationsUnavailable
InvalidLogin
FileNotFound
FileAlreadyExists

@michaelrice

This comment has been minimized.

Member

michaelrice commented Feb 20, 2015

Thats wonderful! Ill be working on better coverage over the next couple of weeks, and I am currently hoping to release my next update in late March or early April.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment