Uploaded image for project: 'Couchbase Java Client'
  1. Couchbase Java Client
  2. JCBC-140

Code breaks when Connection URI is improper

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.1-dp3
    • Fix Version/s: 1.1.1
    • Component/s: Core
    • Security Level: Public
    • Labels:
      None
    • Environment:

      Description

      The code breaks abruptly when connection URI is not given in a proper format in the SDK client for connecting the to required Couchbase server.
      For instance, when I am specifying the URI as "http:/10.3.2.57:8091/index.html" instead of "http:/10.3.2.57:8091/pools", exception appears,
      whereas a proper error message should be returned saying that 'Connection could not be established to the requested server location'.
      Please find attached the log file for the exception trace.

      No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

        deeptida Deepti Dawar created issue -
        deeptida Deepti Dawar made changes -
        Field Original Value New Value
        Description The code breaks abruptly when connection URI is not given in a proper format.
        For instance, when I am specifying the URI as http:/10.3.2.57:8091/index.html, exception appears,
        whereas a proper error message should be returned saying that Connection could not be established to the requested server location.
        Please find attached the log file for the exception trace.
        The code breaks abruptly when connection URI is not given in a proper format in the SDK client for connecting the to required Couchbase server.
        For instance, when I am specifying the URI as "http:/10.3.2.57:8091/index.html" instead of "http:/10.3.2.57:8091/pools", exception appears,
        whereas a proper error message should be returned saying that 'Connection could not be established to the requested server location'.
        Please find attached the log file for the exception trace.
        Hide
        daschl Michael Nitschinger added a comment -

        Deepti,

        I think the logs already provide a helpful error message with the stack trace that shows what it tried to parse.

        In the case you provided, the logs would say 2012-11-08 10:29:09.254 WARN com.couchbase.client.vbucket.ConfigurationProviderHTTP: Provided URI http://192.168.1.105:8091/index.html has an unparsable response...skipping

        and then print a stack trace of what was tried to parse (in this case hughe chunks of HTML).

        Also, if you pass in more URIs it would try to get the next one to establish a successful connection.

        I think we could catch it and add a different error message, but then it wont be clear to the user what happened.

        If you think we really should change something here, please reopen the issue and then we can discuss it together at a broader audience!

        Thanks,
        Michael

        Show
        daschl Michael Nitschinger added a comment - Deepti, I think the logs already provide a helpful error message with the stack trace that shows what it tried to parse. In the case you provided, the logs would say 2012-11-08 10:29:09.254 WARN com.couchbase.client.vbucket.ConfigurationProviderHTTP: Provided URI http://192.168.1.105:8091/index.html has an unparsable response...skipping and then print a stack trace of what was tried to parse (in this case hughe chunks of HTML). Also, if you pass in more URIs it would try to get the next one to establish a successful connection. I think we could catch it and add a different error message, but then it wont be clear to the user what happened. If you think we really should change something here, please reopen the issue and then we can discuss it together at a broader audience! Thanks, Michael
        daschl Michael Nitschinger made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Assignee Raghavan Srinivas [ rags ] Michael Nitschinger [ daschl ]
        Resolution Won't Fix [ 2 ]
        Hide
        deeptida Deepti Dawar added a comment -

        Dear Michael,

        As discussed with you, I think the exception here should be caught in a very generic manner that gives the user some information like this - "Connection could not be established - Either the URI provided is incorrect or the host is unavailable". As the user is not concerned about what is happening beyond the scene and not in the least about what is getting parsed in order for the connection to be established. He is just concerned about the system URL he wants to connect to and the network. Either of these two if unavailable with cause an issue in connection, only that needs to be highlighted back to the user in form of a warning message. It should not abruptly break the code. Hence, I am reopening this defect for further investigation.

        Regards,
        Deepti

        Show
        deeptida Deepti Dawar added a comment - Dear Michael, As discussed with you, I think the exception here should be caught in a very generic manner that gives the user some information like this - "Connection could not be established - Either the URI provided is incorrect or the host is unavailable". As the user is not concerned about what is happening beyond the scene and not in the least about what is getting parsed in order for the connection to be established. He is just concerned about the system URL he wants to connect to and the network. Either of these two if unavailable with cause an issue in connection, only that needs to be highlighted back to the user in form of a warning message. It should not abruptly break the code. Hence, I am reopening this defect for further investigation. Regards, Deepti
        deeptida Deepti Dawar made changes -
        Resolution Won't Fix [ 2 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        daschl Michael Nitschinger made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Fix Version/s 1.1-dp5 [ 10410 ]
        daschl Michael Nitschinger made changes -
        Assignee Michael Nitschinger [ daschl ] Matt Ingenthron [ ingenthr ]
        daschl Michael Nitschinger made changes -
        Fix Version/s 1.1beta [ 10370 ]
        Fix Version/s 1.1-dp5 [ 10410 ]
        ingenthr Matt Ingenthron made changes -
        Fix Version/s 1.1.0 [ 10274 ]
        Fix Version/s 1.1-beta [ 10370 ]
        daschl Michael Nitschinger made changes -
        Fix Version/s 1.1.1 [ 10430 ]
        Fix Version/s 1.1.0 [ 10274 ]
        deeptida Deepti Dawar made changes -
        Assignee Matt Ingenthron [ ingenthr ] Deepti Dawar [ deeptida ]
        Hide
        deeptida Deepti Dawar added a comment -

        File changed.
        Please approve for check in.

        Show
        deeptida Deepti Dawar added a comment - File changed. Please approve for check in.
        deeptida Deepti Dawar made changes -
        Attachment ConfigurationParserJSON.java [ 16066 ]
        Hide
        deeptida Deepti Dawar added a comment -

        Hi Michael,

        Please review at

        http://review.couchbase.org/#/c/23648/2

        Regards,
        Deepti

        Show
        deeptida Deepti Dawar added a comment - Hi Michael, Please review at http://review.couchbase.org/#/c/23648/2 Regards, Deepti
        Hide
        mnunberg Mark Nunberg added a comment -

        I think this should be converted to some kind of connection or execution exception, providing more detailed information.

        Show
        mnunberg Mark Nunberg added a comment - I think this should be converted to some kind of connection or execution exception, providing more detailed information.
        Hide
        deeptida Deepti Dawar added a comment -

        Mark, can we have any exceptions like DisplayableException which could be shown to the end user ?

        Can you please give details about the connection or execution exceptions.

        Show
        deeptida Deepti Dawar added a comment - Mark, can we have any exceptions like DisplayableException which could be shown to the end user ? Can you please give details about the connection or execution exceptions.
        Hide
        mnunberg Mark Nunberg added a comment -

        What is displayed to the user is a sub-component of logging and not of the exception itself. An exception is not an exception unless it represents an exceptional condition; it is up to the code catching the exception to convert this to something the user can understand.

        I am not sure if the Couchbase Java client has classes for "connection" exceptions which indicate a difficulty in communication between client and server, but if there isn't such a class then it should be created.

        Theroetically

        class CouchbaseConnectionException extends Exception

        { .... }

        Typically it seems most of the Couchbase exceptions in the Java client are RuntimeExceptions or ExecutionExceptions (i.e. generic "unchecked" exceptions).

        Matt and Michale might have more knowledge of the various classes contained therein and their suitability of use.

        Show
        mnunberg Mark Nunberg added a comment - What is displayed to the user is a sub-component of logging and not of the exception itself. An exception is not an exception unless it represents an exceptional condition; it is up to the code catching the exception to convert this to something the user can understand. I am not sure if the Couchbase Java client has classes for "connection" exceptions which indicate a difficulty in communication between client and server, but if there isn't such a class then it should be created. Theroetically class CouchbaseConnectionException extends Exception { .... } Typically it seems most of the Couchbase exceptions in the Java client are RuntimeExceptions or ExecutionExceptions (i.e. generic "unchecked" exceptions). Matt and Michale might have more knowledge of the various classes contained therein and their suitability of use.
        Hide
        deeptida Deepti Dawar added a comment - - edited

        I agree. There should be in-house exception classes meant to facilitate this purpose.
        A user working with couchbase sdk, should have the feasibility of using those exception classes for understanding various scenarios and then acting accordingly.

        Please let us know if there are any exception classes for communicating the connection exception to the user in which we can embed a custom message stating what happened.

        Show
        deeptida Deepti Dawar added a comment - - edited I agree. There should be in-house exception classes meant to facilitate this purpose. A user working with couchbase sdk, should have the feasibility of using those exception classes for understanding various scenarios and then acting accordingly. Please let us know if there are any exception classes for communicating the connection exception to the user in which we can embed a custom message stating what happened.
        deeptida Deepti Dawar made changes -
        Comment [ I agree. There should be in-house exception classes meant to facilitate this purpose.
        A user working with couchbase sdk, should have the feasibility of using those exception classes for indicating various scenarios to the user.

        Please let us know if there are any exception classes for displaying the exceptions. ]
        Hide
        deeptida Deepti Dawar added a comment -
        Show
        deeptida Deepti Dawar added a comment - Please review at http://review.couchbase.org/#/c/23648/
        Hide
        deeptida Deepti Dawar added a comment -

        Changes checked in for review in gerrit.

        Show
        deeptida Deepti Dawar added a comment - Changes checked in for review in gerrit.
        deeptida Deepti Dawar made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        deeptida Deepti Dawar made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        ingenthr Matt Ingenthron made changes -
        Workflow jira [ 21598 ] Couchbase SDK Workflow [ 38424 ]

          People

          • Assignee:
            deeptida Deepti Dawar
            Reporter:
            deeptida Deepti Dawar
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Gerrit Reviews

              There are no open Gerrit changes