[jbosstools-issues] [JBoss JIRA] (JBIDE-13794) openshift-java-client: cannot get json response from exception

Andre Dietisheim (JIRA) jira-events at lists.jboss.org
Fri Mar 15 06:46:42 EDT 2013


    [ https://issues.jboss.org/browse/JBIDE-13794?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761327#comment-12761327 ] 

Andre Dietisheim commented on JBIDE-13794:
------------------------------------------

Removed server url (-error message) from HttpClientException since this is preventing users from getting the json from the wrapping OpenShiftEndpointException. Made sure the OpenshiftTimeoutException reports the full server url.

Verified by running the tests locally, that the timeout exception still reports the full server url:

{quote}
com.openshift.client.OpenShiftEndpointException: Could not request https://stg.openshift.redhat.com/broker/rest/api: java.net.ConnectException: Connection timed out
	at com.openshift.internal.client.RestService.request(RestService.java:106)
	at com.openshift.internal.client.RestService.request(RestService.java:91)
	at com.openshift.internal.client.RestService.request(RestService.java:72)
	at com.openshift.internal.client.AbstractOpenShiftConnectionFactory.getConnection(AbstractOpenShiftConnectionFactory.java:35)
	at com.openshift.client.OpenShiftConnectionFactory.getConnection(OpenShiftConnectionFactory.java:134)
	at com.openshift.client.utils.TestConnectionFactory.getConnection(TestConnectionFactory.java:32)
	at com.openshift.internal.client.DomainResourceIntegrationTest.setUp(DomainResourceIntegrationTest.java:44)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
	at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: com.openshift.internal.client.httpclient.HttpClientException: java.net.ConnectException: Connection timed out
	at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:199)
	at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.get(UrlConnectionHttpClient.java:103)
	at com.openshift.internal.client.RestService.request(RestService.java:139)
	at com.openshift.internal.client.RestService.request(RestService.java:98)
	... 29 more
Caused by: java.net.ConnectException: Connection timed out
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1491)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1485)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)
	at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.createException(UrlConnectionHttpClient.java:182)
	... 32 more
Caused by: java.net.ConnectException: Connection timed out
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:529)
	at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:559)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:161)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:395)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:530)
	at sun.net.www.protocol.https.HttpsClient.<init>(HttpsClient.java:272)
	at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:329)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:172)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:911)
	at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:158)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)
	at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:234)
	at com.openshift.internal.client.httpclient.UrlConnectionHttpClient.get(UrlConnectionHttpClient.java:101)
	... 31 more

{quote}
                
> openshift-java-client: cannot get json response from exception
> --------------------------------------------------------------
>
>                 Key: JBIDE-13794
>                 URL: https://issues.jboss.org/browse/JBIDE-13794
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: openshift
>    Affects Versions: 4.1.0.Alpha2
>            Reporter: Andre Dietisheim
>            Assignee: Andre Dietisheim
>             Fix For: 4.1.0.Alpha2
>
>
> With the change in JBIDE-13763, which implemented human readable exceptions that tell the user to what server the exception was occurring, we lost the ability to get the json from the exception. This is not ideal since the json contains the exact error message and error code from the server.
> Before JBIDE-13763 *OpenShiftEndpointException* reported the server returned json as object when one called *OpenShiftEndpointException#getRestResponse*. OpenShiftEndpointException internally by getting the message from the HttpClientException it is wrapping:
> {code:title=RestService#request}
> 		} catch (HttpClientException e) {
> 			throw new OpenShiftEndpointException(
> 					url.toString(), e, e.getMessage(),
> 					"Could not request {0}: {1}", url.toString(), getResponseMessage(e));
> {code}
> before JBIDE-13763: 
> {code:title=HttpClientException.getMessage()}
> {
>    "data":null,
>    "errors":{
>    },
>    "messages":[
>       {
>          "exit_code":128,
>          "field":null,
>          "severity":"error",
>          "text":"Domain contains applications. Delete applications first or set force to true."
>       }
>    ],
>    "status":"bad_request",
>    "supported_api_versions":[
>       1.0,
>       1.1,
>       1.2,
>       1.3
>    ],
>    "type":null,
>    "version":"1.0"
> }
> {code}
> after JBIDE-13763:
> {code:title=HttpClientException.getMessage()}
> Connection to https://stg.openshift.redhat.com/broker/rest/domains/1363341069128, {
>    "data":null,
>    "errors":{
>    },
>    "messages":[
>       {
>          "exit_code":128,
>          "field":null,
>          "severity":"error",
>          "text":"Domain contains applications. Delete applications first or set force to true."
>       }
>    ],
>    "status":"bad_request",
>    "supported_api_versions":[
>       1.0,
>       1.1,
>       1.2,
>       1.3
>    ],
>    "type":null,
>    "version":"1.0"
> }
> {code}
> When the user asks the OpenShiftEndpointException for the json from the server it would call OpenShiftEndpointException#getRestResponse() which would parse the message from json and return a RestResponse object.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jbosstools-issues mailing list