From 6eb2be2cb83e4e292ebaf192c44940d14b563745 Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Sun, 8 Mar 2020 21:29:38 -0700 Subject: [PATCH 1/8] fix: include request URL into GoogleJsonResponseException message --- .../json/GoogleJsonResponseException.java | 3 ++ .../json/GoogleJsonResponseExceptionTest.java | 33 ++++++++++++++----- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java index f6cf41ba0..d22bb0c11 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java @@ -140,6 +140,9 @@ public static GoogleJsonResponseException from(JsonFactory jsonFactory, HttpResp } // message StringBuilder message = HttpResponseException.computeMessageBuffer(response); + (message.length() == 0 ? message : message.append(StringUtils.LINE_SEPARATOR)) + .append("Request URL: ") + .append(response.getRequest().getUrl()); if (!com.google.api.client.util.Strings.isNullOrEmpty(detailString)) { message.append(StringUtils.LINE_SEPARATOR).append(detailString); builder.setContent(detailString); diff --git a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java index e61b421fb..083ee81b5 100644 --- a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java +++ b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java @@ -15,6 +15,7 @@ package com.google.api.client.googleapis.json; import com.google.api.client.googleapis.json.GoogleJsonErrorTest.ErrorTransport; +import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpTransport; @@ -42,7 +43,7 @@ public void testFrom_noDetails() throws Exception { GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); - assertEquals("200", ge.getMessage()); + assertEquals("200" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); } public void testFrom_withDetails() throws Exception { @@ -55,7 +56,13 @@ public void testFrom_withDetails() throws Exception { GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertEquals(GoogleJsonErrorTest.ERROR, GoogleJsonErrorTest.FACTORY.toString(ge.getDetails())); assertTrue( - ge.getMessage(), ge.getMessage().startsWith("403" + StringUtils.LINE_SEPARATOR + "{")); + ge.getMessage(), + ge.getMessage() + .startsWith( + "403" + + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL) + + StringUtils.LINE_SEPARATOR + + "{")); } public void testFrom_detailsMissingContent() throws Exception { @@ -67,7 +74,7 @@ public void testFrom_detailsMissingContent() throws Exception { GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); - assertEquals("403", ge.getMessage()); + assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); } public void testFrom_detailsArbitraryJsonContent() throws Exception { @@ -79,7 +86,7 @@ public void testFrom_detailsArbitraryJsonContent() throws Exception { GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); - assertEquals("403", ge.getMessage()); + assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); } public void testFrom_detailsArbitraryXmlContent() throws Exception { @@ -92,7 +99,13 @@ public void testFrom_detailsArbitraryXmlContent() throws Exception { GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); assertTrue( - ge.getMessage(), ge.getMessage().startsWith("403" + StringUtils.LINE_SEPARATOR + "<")); + ge.getMessage(), + ge.getMessage() + .startsWith( + "403" + + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL) + + StringUtils.LINE_SEPARATOR + + "<")); } public void testFrom_errorNoContentButWithJsonContentType() throws Exception { @@ -104,7 +117,7 @@ public void testFrom_errorNoContentButWithJsonContentType() throws Exception { GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); - assertEquals("403", ge.getMessage()); + assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); } public void testFrom_errorEmptyContentButWithJsonContentType() throws Exception { @@ -116,7 +129,7 @@ public void testFrom_errorEmptyContentButWithJsonContentType() throws Exception GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); - assertEquals("403", ge.getMessage()); + assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); } public void testFrom_detailsErrorObject() throws Exception { @@ -154,6 +167,10 @@ public void testFrom_detailsNoErrorField() throws Exception { GoogleJsonResponseException ge = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(ge.getDetails()); - assertEquals("403", ge.getMessage()); + assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + } + + private static String getRequestUrlMessage(GenericUrl requestUrl) { + return StringUtils.LINE_SEPARATOR + "Request URL: " + requestUrl; } } From c46ae01c17472d88a53044684cb0ac16c72c8eae Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Mon, 9 Mar 2020 12:20:57 -0700 Subject: [PATCH 2/8] fix: make implementation more readable --- .../googleapis/json/GoogleJsonResponseException.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java index d22bb0c11..636722aee 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java @@ -140,9 +140,10 @@ public static GoogleJsonResponseException from(JsonFactory jsonFactory, HttpResp } // message StringBuilder message = HttpResponseException.computeMessageBuffer(response); - (message.length() == 0 ? message : message.append(StringUtils.LINE_SEPARATOR)) - .append("Request URL: ") - .append(response.getRequest().getUrl()); + if (message.length() > 0) { + message.append(StringUtils.LINE_SEPARATOR); + } + message.append("Request URL: ").append(response.getRequest().getUrl()); if (!com.google.api.client.util.Strings.isNullOrEmpty(detailString)) { message.append(StringUtils.LINE_SEPARATOR).append(detailString); builder.setContent(detailString); From 8289ed191d39e814a08968deeb6421bc4d518a44 Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Mon, 9 Mar 2020 13:08:34 -0700 Subject: [PATCH 3/8] fix: improve tests readability --- .../json/GoogleJsonResponseExceptionTest.java | 90 +++++++++---------- 1 file changed, 45 insertions(+), 45 deletions(-) diff --git a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java index 083ee81b5..a1addb8d8 100644 --- a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java +++ b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java @@ -40,10 +40,11 @@ public void testFrom_noDetails() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertEquals("200" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + assertNull(responseException.getDetails()); + String expectedMessage = "200" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + assertEquals(expectedMessage, responseException.getMessage()); } public void testFrom_withDetails() throws Exception { @@ -52,17 +53,15 @@ public void testFrom_withDetails() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertEquals(GoogleJsonErrorTest.ERROR, GoogleJsonErrorTest.FACTORY.toString(ge.getDetails())); + assertEquals( + GoogleJsonErrorTest.ERROR, + GoogleJsonErrorTest.FACTORY.toString(responseException.getDetails())); + String expectedMessage = + "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL) + StringUtils.LINE_SEPARATOR + "{"; assertTrue( - ge.getMessage(), - ge.getMessage() - .startsWith( - "403" - + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL) - + StringUtils.LINE_SEPARATOR - + "{")); + responseException.getMessage(), responseException.getMessage().startsWith(expectedMessage)); } public void testFrom_detailsMissingContent() throws Exception { @@ -71,10 +70,11 @@ public void testFrom_detailsMissingContent() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + assertNull(responseException.getDetails()); + String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + assertEquals(expectedMessage, responseException.getMessage()); } public void testFrom_detailsArbitraryJsonContent() throws Exception { @@ -83,10 +83,11 @@ public void testFrom_detailsArbitraryJsonContent() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + assertNull(responseException.getDetails()); + String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + assertEquals(expectedMessage, responseException.getMessage()); } public void testFrom_detailsArbitraryXmlContent() throws Exception { @@ -95,17 +96,13 @@ public void testFrom_detailsArbitraryXmlContent() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); + assertNull(responseException.getDetails()); + String expectedMessage = + "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL) + StringUtils.LINE_SEPARATOR + "<"; assertTrue( - ge.getMessage(), - ge.getMessage() - .startsWith( - "403" - + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL) - + StringUtils.LINE_SEPARATOR - + "<")); + responseException.getMessage(), responseException.getMessage().startsWith(expectedMessage)); } public void testFrom_errorNoContentButWithJsonContentType() throws Exception { @@ -114,10 +111,11 @@ public void testFrom_errorNoContentButWithJsonContentType() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + assertNull(responseException.getDetails()); + String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + assertEquals(expectedMessage, responseException.getMessage()); } public void testFrom_errorEmptyContentButWithJsonContentType() throws Exception { @@ -126,10 +124,11 @@ public void testFrom_errorEmptyContentButWithJsonContentType() throws Exception transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + assertNull(responseException.getDetails()); + String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + assertEquals(expectedMessage, responseException.getMessage()); } public void testFrom_detailsErrorObject() throws Exception { @@ -138,11 +137,11 @@ public void testFrom_detailsErrorObject() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNotNull(ge.getDetails()); - assertEquals("invalid_token", ge.getDetails().getMessage()); - assertTrue(ge.getMessage().contains("403")); + assertNotNull(responseException.getDetails()); + assertEquals("invalid_token", responseException.getDetails().getMessage()); + assertTrue(responseException.getMessage().contains("403")); } public void testFrom_detailsErrorString() throws Exception { @@ -151,11 +150,11 @@ public void testFrom_detailsErrorString() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertTrue(ge.getMessage().contains("403")); - assertTrue(ge.getMessage().contains("invalid_token")); + assertNull(responseException.getDetails()); + assertTrue(responseException.getMessage().contains("403")); + assertTrue(responseException.getMessage().contains("invalid_token")); } public void testFrom_detailsNoErrorField() throws Exception { @@ -164,13 +163,14 @@ public void testFrom_detailsNoErrorField() throws Exception { transport.createRequestFactory().buildGetRequest(HttpTesting.SIMPLE_GENERIC_URL); request.setThrowExceptionOnExecuteError(false); HttpResponse response = request.execute(); - GoogleJsonResponseException ge = + GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); - assertNull(ge.getDetails()); - assertEquals("403" + getRequestUrlMessage(HttpTesting.SIMPLE_GENERIC_URL), ge.getMessage()); + assertNull(responseException.getDetails()); + String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + assertEquals(expectedMessage, responseException.getMessage()); } - private static String getRequestUrlMessage(GenericUrl requestUrl) { + private static String getRequestUrl(GenericUrl requestUrl) { return StringUtils.LINE_SEPARATOR + "Request URL: " + requestUrl; } } From 327a5e84e09223171cc3f05c3a3f6d26680a0bc1 Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Fri, 13 Mar 2020 09:31:05 -0700 Subject: [PATCH 4/8] Make exception message platform independent --- .../api/client/googleapis/json/GoogleJsonResponseException.java | 2 +- .../client/googleapis/json/GoogleJsonResponseExceptionTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java index 636722aee..db39234ae 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java @@ -141,7 +141,7 @@ public static GoogleJsonResponseException from(JsonFactory jsonFactory, HttpResp // message StringBuilder message = HttpResponseException.computeMessageBuffer(response); if (message.length() > 0) { - message.append(StringUtils.LINE_SEPARATOR); + message.append("\n"); } message.append("Request URL: ").append(response.getRequest().getUrl()); if (!com.google.api.client.util.Strings.isNullOrEmpty(detailString)) { diff --git a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java index a1addb8d8..6a24cf316 100644 --- a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java +++ b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java @@ -171,6 +171,6 @@ public void testFrom_detailsNoErrorField() throws Exception { } private static String getRequestUrl(GenericUrl requestUrl) { - return StringUtils.LINE_SEPARATOR + "Request URL: " + requestUrl; + return "\nRequest URL: " + requestUrl; } } From 35a3379c44d574e4ee05a5faff0fe763caf8b99d Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Mon, 16 Mar 2020 06:29:11 -0700 Subject: [PATCH 5/8] Upgrade to HTTP client that logs exception message --- .../json/GoogleJsonResponseExceptionTest.java | 20 ++++++++----------- pom.xml | 2 +- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java index 6a24cf316..2df5437ea 100644 --- a/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java +++ b/google-api-client/src/test/java/com/google/api/client/googleapis/json/GoogleJsonResponseExceptionTest.java @@ -15,7 +15,6 @@ package com.google.api.client.googleapis.json; import com.google.api.client.googleapis.json.GoogleJsonErrorTest.ErrorTransport; -import com.google.api.client.http.GenericUrl; import com.google.api.client.http.HttpRequest; import com.google.api.client.http.HttpResponse; import com.google.api.client.http.HttpTransport; @@ -43,7 +42,7 @@ public void testFrom_noDetails() throws Exception { GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); - String expectedMessage = "200" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + String expectedMessage = "200\nGET " + HttpTesting.SIMPLE_GENERIC_URL; assertEquals(expectedMessage, responseException.getMessage()); } @@ -59,7 +58,7 @@ public void testFrom_withDetails() throws Exception { GoogleJsonErrorTest.ERROR, GoogleJsonErrorTest.FACTORY.toString(responseException.getDetails())); String expectedMessage = - "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL) + StringUtils.LINE_SEPARATOR + "{"; + "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL + StringUtils.LINE_SEPARATOR + "{"; assertTrue( responseException.getMessage(), responseException.getMessage().startsWith(expectedMessage)); } @@ -73,7 +72,7 @@ public void testFrom_detailsMissingContent() throws Exception { GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); - String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL; assertEquals(expectedMessage, responseException.getMessage()); } @@ -86,7 +85,7 @@ public void testFrom_detailsArbitraryJsonContent() throws Exception { GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); - String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL; assertEquals(expectedMessage, responseException.getMessage()); } @@ -100,7 +99,7 @@ public void testFrom_detailsArbitraryXmlContent() throws Exception { GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); String expectedMessage = - "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL) + StringUtils.LINE_SEPARATOR + "<"; + "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL + StringUtils.LINE_SEPARATOR + "<"; assertTrue( responseException.getMessage(), responseException.getMessage().startsWith(expectedMessage)); } @@ -114,7 +113,7 @@ public void testFrom_errorNoContentButWithJsonContentType() throws Exception { GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); - String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL; assertEquals(expectedMessage, responseException.getMessage()); } @@ -127,7 +126,7 @@ public void testFrom_errorEmptyContentButWithJsonContentType() throws Exception GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); - String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL; assertEquals(expectedMessage, responseException.getMessage()); } @@ -166,11 +165,8 @@ public void testFrom_detailsNoErrorField() throws Exception { GoogleJsonResponseException responseException = GoogleJsonResponseException.from(GoogleJsonErrorTest.FACTORY, response); assertNull(responseException.getDetails()); - String expectedMessage = "403" + getRequestUrl(HttpTesting.SIMPLE_GENERIC_URL); + String expectedMessage = "403\nGET " + HttpTesting.SIMPLE_GENERIC_URL; assertEquals(expectedMessage, responseException.getMessage()); } - private static String getRequestUrl(GenericUrl requestUrl) { - return "\nRequest URL: " + requestUrl; - } } diff --git a/pom.xml b/pom.xml index fca135b59..3aa1f0125 100644 --- a/pom.xml +++ b/pom.xml @@ -449,7 +449,7 @@ UTF-8 - 1.34.2 + 1.34.3 1.30.6 3.0.2 2.8.6 From b22d1e2646a00594ee31d387140c23d9f9ddb7a6 Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Mon, 16 Mar 2020 06:33:29 -0700 Subject: [PATCH 6/8] Delete exception message code --- .../client/googleapis/json/GoogleJsonResponseException.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java index db39234ae..f6cf41ba0 100644 --- a/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java +++ b/google-api-client/src/main/java/com/google/api/client/googleapis/json/GoogleJsonResponseException.java @@ -140,10 +140,6 @@ public static GoogleJsonResponseException from(JsonFactory jsonFactory, HttpResp } // message StringBuilder message = HttpResponseException.computeMessageBuffer(response); - if (message.length() > 0) { - message.append("\n"); - } - message.append("Request URL: ").append(response.getRequest().getUrl()); if (!com.google.api.client.util.Strings.isNullOrEmpty(detailString)) { message.append(StringUtils.LINE_SEPARATOR).append(detailString); builder.setContent(detailString); From f4ba31bc5daef2540cd67a6db09a46a3c543efff Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Sat, 2 May 2020 18:34:08 -0700 Subject: [PATCH 7/8] Update google-http-java-client --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3aa1f0125..e0017e74b 100644 --- a/pom.xml +++ b/pom.xml @@ -449,7 +449,7 @@ UTF-8 - 1.34.3 + 1.35.0 1.30.6 3.0.2 2.8.6 From 9f4fde2f844a86949fa11ef300ed65b3a6d4c160 Mon Sep 17 00:00:00 2001 From: Igor Dvorzhak Date: Tue, 30 Jun 2020 22:48:23 -0700 Subject: [PATCH 8/8] Update pom.xml --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d3975eb45..91bb56fc0 100644 --- a/pom.xml +++ b/pom.xml @@ -449,7 +449,7 @@ UTF-8 - 1.35.0 + 1.36.0 1.31.0 3.0.2 2.8.6