Derby
  1. Derby
  2. DERBY-1069

Client should unwrap exceptions thrown in privilege blocks rather than throwing the java.security.PrivilegedActionException

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 10.1.3.1, 10.2.1.6
    • Component/s: Network Client
    • Labels:
      None

      Description

      Can lead to misunderstanding the root cause of the problem.

        Activity

        Hide
        David Van Couvering added a comment -

        I search for all instances of PrivilegedActionException in the trunk, and all these appear to be correcty unwrapping the exception. I'll check the 10.1 code base.

        Show
        David Van Couvering added a comment - I search for all instances of PrivilegedActionException in the trunk, and all these appear to be correcty unwrapping the exception. I'll check the 10.1 code base.
        Hide
        Kathey Marsden added a comment -

        on 10.2 if I connect without network server up I see the java.security.PrivilegedActionException in the message.

        ij> connect 'jdbc:derby://localhost:1527/wombat';
        ERROR 08001: java.security.PrivilegedActionException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.

        Show
        Kathey Marsden added a comment - on 10.2 if I connect without network server up I see the java.security.PrivilegedActionException in the message. ij> connect 'jdbc:derby://localhost:1527/wombat'; ERROR 08001: java.security.PrivilegedActionException : Error connecting to server localhost on port 1,527 with message Connection refused: connect.
        Hide
        David Van Couvering added a comment -

        Hm. In the source code I have:

        try

        { socket_ = (java.net.Socket) java.security.AccessController.doPrivileged(new OpenSocketAction(server, port)); }

        catch (java.security.PrivilegedActionException e) {
        throw new DisconnectException(this,
        new ClientMessageId(SQLState.CONNECT_UNABLE_TO_CONNECT_TO_SERVER),
        new Object[]

        { e.getClass().getName(), server, new Integer(port), e.getException().getMessage() }

        ,
        e.getException());
        }

        So, we are unwrapping the exception to get the message, and chaining the unwrapped exception. However, the name of the original exception is not used as the first parameter in the Object array. That I can fix.

        But, what happens to the stack trace when you use ij? Do you have to enable logging to see it?

        Show
        David Van Couvering added a comment - Hm. In the source code I have: try { socket_ = (java.net.Socket) java.security.AccessController.doPrivileged(new OpenSocketAction(server, port)); } catch (java.security.PrivilegedActionException e) { throw new DisconnectException(this, new ClientMessageId(SQLState.CONNECT_UNABLE_TO_CONNECT_TO_SERVER), new Object[] { e.getClass().getName(), server, new Integer(port), e.getException().getMessage() } , e.getException()); } So, we are unwrapping the exception to get the message, and chaining the unwrapped exception. However, the name of the original exception is not used as the first parameter in the Object array. That I can fix. But, what happens to the stack trace when you use ij? Do you have to enable logging to see it?
        Hide
        David Van Couvering added a comment -

        OK, with a fix to the above code, I have in ij:

        ij version 10.2
        ij> connect 'jdbc:derby://localhost:1527/wombat';
        ERROR 08001: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused.
        ij>

        Is this what we are looking for?

        Show
        David Van Couvering added a comment - OK, with a fix to the above code, I have in ij: ij version 10.2 ij> connect 'jdbc:derby://localhost:1527/wombat'; ERROR 08001: java.net.ConnectException : Error connecting to server localhost on port 1,527 with message Connection refused. ij> Is this what we are looking for?
        Hide
        Daniel John Debrunner added a comment -

        Looks good, directs people to the actual problem, rather than confusing them.

        Show
        Daniel John Debrunner added a comment - Looks good, directs people to the actual problem, rather than confusing them.
        Hide
        David Van Couvering added a comment -

        Fixed in 10.2, revision 41136. Need to do a similar fix in the 10.1 branch

        Show
        David Van Couvering added a comment - Fixed in 10.2, revision 41136. Need to do a similar fix in the 10.1 branch
        Hide
        David Van Couvering added a comment -

        Fixed in the 10.1 branch as well now. Here's the new output from ij:

        ERROR (no SQLState): java.net.ConnectException : Error opening socket to server localhost on port 1527 with message : Connection refused

        In the trunk you get an actual SQL state, and the trace file will contain the stack trace with all causes. Note I also fixed the port number so it is formatted correctly.

        Show
        David Van Couvering added a comment - Fixed in the 10.1 branch as well now. Here's the new output from ij: ERROR (no SQLState): java.net.ConnectException : Error opening socket to server localhost on port 1527 with message : Connection refused In the trunk you get an actual SQL state, and the trace file will contain the stack trace with all causes. Note I also fixed the port number so it is formatted correctly.
        Hide
        Kathey Marsden added a comment -

        Adding 10.1.2.5 for the current snapshot version.
        Thanks David for the fix!

        Show
        Kathey Marsden added a comment - Adding 10.1.2.5 for the current snapshot version. Thanks David for the fix!
        Hide
        Andrew McIntyre added a comment -

        This issue has been resolved for over a year with no further movement. Closing.

        Show
        Andrew McIntyre added a comment - This issue has been resolved for over a year with no further movement. Closing.

          People

          • Assignee:
            David Van Couvering
            Reporter:
            Daniel John Debrunner
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development