diff --git a/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ApacheHttpTransport.java b/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ApacheHttpTransport.java index 864dd072f..02fb98a35 100644 --- a/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ApacheHttpTransport.java +++ b/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ApacheHttpTransport.java @@ -38,19 +38,15 @@ /** * Thread-safe HTTP transport based on the Apache HTTP Client library. * - *

- * Implementation is thread-safe, as long as any parameter modification to the - * {@link #getHttpClient() Apache HTTP Client} is only done at initialization time. For maximum - * efficiency, applications should use a single globally-shared instance of the HTTP transport. - *

+ *

Implementation is thread-safe, as long as any parameter modification to the {@link + * #getHttpClient() Apache HTTP Client} is only done at initialization time. For maximum efficiency, + * applications should use a single globally-shared instance of the HTTP transport. * - *

- * Default settings are specified in {@link #newDefaultHttpClient()}. Use the - * {@link #ApacheHttpTransport(HttpClient)} constructor to override the Apache HTTP Client used. - * Please read the Default settings are specified in {@link #newDefaultHttpClient()}. Use the {@link + * #ApacheHttpTransport(HttpClient)} constructor to override the Apache HTTP Client used. Please + * read the Apache HTTP * Client connection management tutorial for more complex configuration options. - *

* * @since 1.30 * @author Yaniv Inbar @@ -72,20 +68,18 @@ public ApacheHttpTransport() { /** * Constructor that allows an alternative Apache HTTP client to be used. * - *

- * Note that in the previous version, we overrode several settings. However, we are no longer able - * to do so. - *

+ *

Note that in the previous version, we overrode several settings. However, we are no longer + * able to do so. + * + *

If you choose to provide your own Apache HttpClient implementation, be sure that * - *

If you choose to provide your own Apache HttpClient implementation, be sure that

* * * @param httpClient Apache HTTP client to use - * * @since 1.30 */ public ApacheHttpTransport(HttpClient httpClient) { @@ -93,20 +87,19 @@ public ApacheHttpTransport(HttpClient httpClient) { } /** - * Creates a new instance of the Apache HTTP client that is used by the - * {@link #ApacheHttpTransport()} constructor. + * Creates a new instance of the Apache HTTP client that is used by the {@link + * #ApacheHttpTransport()} constructor. + * + *

Settings: * - *

- * Settings: - *

* * * @return new instance of the Apache HTTP client @@ -117,20 +110,19 @@ public static HttpClient newDefaultHttpClient() { } /** - * Creates a new Apache HTTP client builder that is used by the - * {@link #ApacheHttpTransport()} constructor. + * Creates a new Apache HTTP client builder that is used by the {@link #ApacheHttpTransport()} + * constructor. + * + *

Settings: * - *

- * Settings: - *

* * * @return new instance of the Apache HTTP client @@ -139,14 +131,14 @@ public static HttpClient newDefaultHttpClient() { public static HttpClientBuilder newDefaultHttpClientBuilder() { return HttpClientBuilder.create() - .useSystemProperties() - .setSSLSocketFactory(SSLConnectionSocketFactory.getSocketFactory()) - .setMaxConnTotal(200) - .setMaxConnPerRoute(20) - .setConnectionTimeToLive(-1, TimeUnit.MILLISECONDS) - .setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault())) - .disableRedirectHandling() - .disableAutomaticRetries(); + .useSystemProperties() + .setSSLSocketFactory(SSLConnectionSocketFactory.getSocketFactory()) + .setMaxConnTotal(200) + .setMaxConnPerRoute(20) + .setConnectionTimeToLive(-1, TimeUnit.MILLISECONDS) + .setRoutePlanner(new SystemDefaultRoutePlanner(ProxySelector.getDefault())) + .disableRedirectHandling() + .disableAutomaticRetries(); } @Override diff --git a/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ContentEntity.java b/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ContentEntity.java index 8fc11e6d8..451b67f2c 100644 --- a/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ContentEntity.java +++ b/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/ContentEntity.java @@ -21,9 +21,7 @@ import java.io.OutputStream; import org.apache.http.entity.AbstractHttpEntity; -/** - * @author Yaniv Inbar - */ +/** @author Yaniv Inbar */ final class ContentEntity extends AbstractHttpEntity { /** Content length or less than zero if not known. */ diff --git a/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/package-info.java b/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/package-info.java index 1909a2f75..7ca1708ad 100644 --- a/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/package-info.java +++ b/google-http-client-apache-v2/src/main/java/com/google/api/client/http/apache/v2/package-info.java @@ -18,6 +18,4 @@ * @since 1.30 * @author Yaniv Inbar */ - package com.google.api.client.http.apache.v2; - diff --git a/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java b/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java index e9b93e9be..880e7fdb6 100644 --- a/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java +++ b/google-http-client-apache-v2/src/test/java/com/google/api/client/http/apache/v2/ApacheHttpTransportTest.java @@ -125,7 +125,8 @@ private void subtestUnsupportedRequestsWithContent(ApacheHttpRequest request, St fail("expected " + IllegalStateException.class); } catch (IllegalStateException e) { // expected - assertEquals(e.getMessage(), + assertEquals( + e.getMessage(), "Apache HTTP client does not support " + method + " requests with content."); } } @@ -141,16 +142,18 @@ private void execute(ApacheHttpRequest request) throws IOException { @Test public void testRequestShouldNotFollowRedirects() throws IOException { final AtomicInteger requestsAttempted = new AtomicInteger(0); - HttpRequestExecutor requestExecutor = new HttpRequestExecutor() { - @Override - public HttpResponse execute(HttpRequest request, HttpClientConnection connection, - HttpContext context) throws IOException, HttpException { - HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 302, null); - response.addHeader("location", "https://google.com/path"); - requestsAttempted.incrementAndGet(); - return response; - } - }; + HttpRequestExecutor requestExecutor = + new HttpRequestExecutor() { + @Override + public HttpResponse execute( + HttpRequest request, HttpClientConnection connection, HttpContext context) + throws IOException, HttpException { + HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 302, null); + response.addHeader("location", "https://google.com/path"); + requestsAttempted.incrementAndGet(); + return response; + } + }; HttpClient client = HttpClients.custom().setRequestExecutor(requestExecutor).build(); ApacheHttpTransport transport = new ApacheHttpTransport(client); ApacheHttpRequest request = transport.buildRequest("GET", "https://google.com"); @@ -162,17 +165,21 @@ public HttpResponse execute(HttpRequest request, HttpClientConnection connection @Test public void testRequestCanSetHeaders() { final AtomicBoolean interceptorCalled = new AtomicBoolean(false); - HttpClient client = HttpClients.custom().addInterceptorFirst(new HttpRequestInterceptor() { - @Override - public void process(HttpRequest request, HttpContext context) - throws HttpException, IOException { - Header header = request.getFirstHeader("foo"); - assertNotNull("Should have found header", header); - assertEquals("bar", header.getValue()); - interceptorCalled.set(true); - throw new IOException("cancelling request"); - } - }).build(); + HttpClient client = + HttpClients.custom() + .addInterceptorFirst( + new HttpRequestInterceptor() { + @Override + public void process(HttpRequest request, HttpContext context) + throws HttpException, IOException { + Header header = request.getFirstHeader("foo"); + assertNotNull("Should have found header", header); + assertEquals("bar", header.getValue()); + interceptorCalled.set(true); + throw new IOException("cancelling request"); + } + }) + .build(); ApacheHttpTransport transport = new ApacheHttpTransport(client); ApacheHttpRequest request = transport.buildRequest("GET", "https://google.com"); @@ -224,10 +231,7 @@ public void handle(HttpExchange httpExchange) throws IOException { GenericUrl testUrl = new GenericUrl("http://localhost/foo//bar"); testUrl.setPort(server.getAddress().getPort()); com.google.api.client.http.HttpResponse response = - transport - .createRequestFactory() - .buildGetRequest(testUrl) - .execute(); + transport.createRequestFactory().buildGetRequest(testUrl).execute(); assertEquals(200, response.getStatusCode()); assertEquals("/foo//bar", response.parseAsString()); } diff --git a/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java b/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java index c22541fb6..83168807c 100644 --- a/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java +++ b/google-http-client-findbugs/src/main/java/com/google/api/client/findbugs/package-info.java @@ -15,28 +15,26 @@ /** * Findbugs package which supports custom Google APIs Client library findbugs Plugins. * - * Usage on pom.xml: + *

Usage on pom.xml: * *

-  <plugin>
-    <groupId>org.codehaus.mojo</groupId>
-    <artifactId>findbugs-maven-plugin</artifactId>
-    ...
-    <configuration>
-      <plugins>
-        <plugin>
-          <groupId>com.google.http-client</groupId>
-          <artifactId>google-http-client-findbugs</artifactId>
-          <version>${project.http.version}</version>
-        </plugin>
-       </plugins>
-    </configuration>
-    ...
-  </plugin>
+ * <plugin>
+ * <groupId>org.codehaus.mojo</groupId>
+ * <artifactId>findbugs-maven-plugin</artifactId>
+ * ...
+ * <configuration>
+ * <plugins>
+ * <plugin>
+ * <groupId>com.google.http-client</groupId>
+ * <artifactId>google-http-client-findbugs</artifactId>
+ * <version>${project.http.version}</version>
+ * </plugin>
+ * </plugins>
+ * </configuration>
+ * ...
+ * </plugin>
  * 
* * @author Eyal Peled */ - package com.google.api.client.findbugs; - diff --git a/google-http-client-gson/src/test/java/com/google/api/client/json/gson/GsonParserTest.java b/google-http-client-gson/src/test/java/com/google/api/client/json/gson/GsonParserTest.java index f79d4a5d6..aa5ed5aea 100644 --- a/google-http-client-gson/src/test/java/com/google/api/client/json/gson/GsonParserTest.java +++ b/google-http-client-gson/src/test/java/com/google/api/client/json/gson/GsonParserTest.java @@ -1,19 +1,16 @@ /** * Copyright 2019 Google LLC * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + *

https://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + *

Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.api.client.json.gson; import com.google.api.client.json.JsonFactory; diff --git a/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java b/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java index 8028d63c6..dba08c363 100644 --- a/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java +++ b/google-http-client-jackson2/src/main/java/com/google/api/client/json/jackson2/JacksonFactory.java @@ -29,8 +29,8 @@ /** * Low-level JSON library implementation based on Jackson 2. * - *

Implementation is thread-safe. For maximum efficiency, - * applications should use a single globally-shared instance of the JSON factory. + *

Implementation is thread-safe. For maximum efficiency, applications should use a single + * globally-shared instance of the JSON factory. * * @since 1.11 * @author Yaniv Inbar diff --git a/google-http-client-jackson2/src/test/java/com/google/api/client/json/jackson2/JacksonParserTest.java b/google-http-client-jackson2/src/test/java/com/google/api/client/json/jackson2/JacksonParserTest.java index 92da03605..ed185c7ab 100644 --- a/google-http-client-jackson2/src/test/java/com/google/api/client/json/jackson2/JacksonParserTest.java +++ b/google-http-client-jackson2/src/test/java/com/google/api/client/json/jackson2/JacksonParserTest.java @@ -1,19 +1,16 @@ /** * Copyright 2019 Google LLC * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + *

https://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + *

Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.api.client.json.jackson2; import com.google.api.client.json.JsonFactory; diff --git a/google-http-client-test/src/main/java/com/google/api/client/test/json/AbstractJsonParserTest.java b/google-http-client-test/src/main/java/com/google/api/client/test/json/AbstractJsonParserTest.java index ef641e868..2a68c639c 100644 --- a/google-http-client-test/src/main/java/com/google/api/client/test/json/AbstractJsonParserTest.java +++ b/google-http-client-test/src/main/java/com/google/api/client/test/json/AbstractJsonParserTest.java @@ -1,19 +1,16 @@ /** * Copyright 2019 Google LLC * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + *

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of the License at * - * https://www.apache.org/licenses/LICENSE-2.0 + *

https://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and + *

Unless required by applicable law or agreed to in writing, software distributed under the + * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either + * express or implied. See the License for the specific language governing permissions and * limitations under the License. */ - package com.google.api.client.test.json; import com.google.api.client.json.GenericJson; diff --git a/google-http-client-xml/src/main/java/com/google/api/client/xml/Xml.java b/google-http-client-xml/src/main/java/com/google/api/client/xml/Xml.java index 4f9156d3c..1aa5a343b 100644 --- a/google-http-client-xml/src/main/java/com/google/api/client/xml/Xml.java +++ b/google-http-client-xml/src/main/java/com/google/api/client/xml/Xml.java @@ -195,10 +195,10 @@ public boolean stopAfterEndTag(String namespace, String localName) { /** * Parses an XML element using the given XML pull parser into the given destination object. * - *

Requires the current event be {@link XmlPullParser#START_TAG} (skipping any initial - * {@link XmlPullParser#START_DOCUMENT}) of the element being parsed. At normal parsing - * completion, the current event will either be {@link XmlPullParser#END_TAG} of the element being - * parsed, or the {@link XmlPullParser#START_TAG} of the requested {@code atom:entry}. + *

Requires the current event be {@link XmlPullParser#START_TAG} (skipping any initial {@link + * XmlPullParser#START_DOCUMENT}) of the element being parsed. At normal parsing completion, the + * current event will either be {@link XmlPullParser#END_TAG} of the element being parsed, or the + * {@link XmlPullParser#START_TAG} of the requested {@code atom:entry}. * * @param parser XML pull parser * @param destination optional destination object to parser into or {@code null} to ignore XML diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffIOExceptionHandler.java b/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffIOExceptionHandler.java index 253cc613e..a0874841f 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffIOExceptionHandler.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffIOExceptionHandler.java @@ -97,6 +97,8 @@ public boolean handleIOException(HttpRequest request, boolean supportsRetry) thr try { return BackOffUtils.next(sleeper, backOff); } catch (InterruptedException exception) { + // Mark thread as interrupted since we cannot throw InterruptedException here. + Thread.currentThread().interrupt(); return false; } } diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffUnsuccessfulResponseHandler.java b/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffUnsuccessfulResponseHandler.java index 5e1ae2cc6..cc44c6136 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffUnsuccessfulResponseHandler.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpBackOffUnsuccessfulResponseHandler.java @@ -128,7 +128,8 @@ public boolean handleResponse(HttpRequest request, HttpResponse response, boolea try { return BackOffUtils.next(sleeper, backOff); } catch (InterruptedException exception) { - // ignore + // Mark thread as interrupted since we cannot throw InterruptedException here. + Thread.currentThread().interrupt(); } } return false; diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpIOExceptionHandler.java b/google-http-client/src/main/java/com/google/api/client/http/HttpIOExceptionHandler.java index f37cfef5e..0b0b877d0 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpIOExceptionHandler.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpIOExceptionHandler.java @@ -35,6 +35,7 @@ * try { * return BackOffUtils.next(sleeper, backOff); * } catch (InterruptedException exception) { + * Thread.currentThread().interrupt(); * return false; * } * } diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java b/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java index 9124e4906..a521c5397 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java @@ -1223,7 +1223,8 @@ private static String getVersion() { // attempt to read the library's version from a properties file generated during the build // this value should be read and cached for later use String version = "unknown-version"; - try (InputStream inputStream = HttpRequest.class.getResourceAsStream("/google-http-client.properties")) { + try (InputStream inputStream = + HttpRequest.class.getResourceAsStream("/google-http-client.properties")) { if (inputStream != null) { final Properties properties = new Properties(); properties.load(inputStream); diff --git a/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java b/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java index 276ce0e74..2df92d4c4 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java +++ b/google-http-client/src/main/java/com/google/api/client/http/HttpResponse.java @@ -159,8 +159,8 @@ public final class HttpResponse { } /** - * Returns an {@link HttpMediaType} object parsed from {@link #contentType}, or {@code null} if - * if {@link #contentType} cannot be parsed or {@link #contentType} is {@code null}. + * Returns an {@link HttpMediaType} object parsed from {@link #contentType}, or {@code null} if if + * {@link #contentType} cannot be parsed or {@link #contentType} is {@code null}. */ private static HttpMediaType parseMediaType(String contentType) { if (contentType == null) { @@ -352,12 +352,14 @@ public InputStream getContent() throws IOException { // gzip encoding (wrap content with GZipInputStream) if (!returnRawInputStream && this.contentEncoding != null) { String oontentencoding = this.contentEncoding.trim().toLowerCase(Locale.ENGLISH); - if (CONTENT_ENCODING_GZIP.equals(oontentencoding) || CONTENT_ENCODING_XGZIP.equals(oontentencoding)) { + if (CONTENT_ENCODING_GZIP.equals(oontentencoding) + || CONTENT_ENCODING_XGZIP.equals(oontentencoding)) { // Wrap the original stream in a ConsumingInputStream before passing it to // GZIPInputStream. The GZIPInputStream leaves content unconsumed in the original // stream (it almost always leaves the last chunk unconsumed in chunked responses). // ConsumingInputStream ensures that any unconsumed bytes are read at close. - // GZIPInputStream.close() --> ConsumingInputStream.close() --> exhaust(ConsumingInputStream) + // GZIPInputStream.close() --> ConsumingInputStream.close() --> + // exhaust(ConsumingInputStream) lowLevelResponseContent = new GZIPInputStream(new ConsumingInputStream(lowLevelResponseContent)); } diff --git a/google-http-client/src/main/java/com/google/api/client/http/MultipartContent.java b/google-http-client/src/main/java/com/google/api/client/http/MultipartContent.java index 43a58b446..35a59cf6f 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/MultipartContent.java +++ b/google-http-client/src/main/java/com/google/api/client/http/MultipartContent.java @@ -32,9 +32,9 @@ * and RFC 2046: Multipurpose Internet * Mail Extensions: The Multipart/mixed (primary) subtype. * - *

By default the media type is {@code "multipart/related; boundary=__END_OF_PART____"}, but this - * may be customized by calling {@link #setMediaType(HttpMediaType)}, {@link #getMediaType()}, or - * {@link #setBoundary(String)}. + *

By default the media type is {@code "multipart/related; boundary=__END_OF_PART____"}, but this may be customized by calling {@link #setMediaType(HttpMediaType)}, {@link + * #getMediaType()}, or {@link #setBoundary(String)}. * *

Implementation is not thread-safe. * diff --git a/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java b/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java index 61071db68..6a1e2e23c 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java +++ b/google-http-client/src/main/java/com/google/api/client/http/UriTemplate.java @@ -104,8 +104,8 @@ private enum CompositeOutput { * @param explodeJoiner the delimiter used to join composite values. * @param requiresVarAssignment denotes whether or not the expanded template should contain an * assignment with the variable - * @param reservedExpansion reserved expansion allows percent-encoded triplets and characters in the - * reserved set + * @param reservedExpansion reserved expansion allows percent-encoded triplets and characters in + * the reserved set */ CompositeOutput( Character propertyPrefix, @@ -149,8 +149,8 @@ int getVarNameStartIndex() { } /** - * Encodes the specified value. If reserved expansion is turned on, then percent-encoded triplets and - * characters are allowed in the reserved set. + * Encodes the specified value. If reserved expansion is turned on, then percent-encoded + * triplets and characters are allowed in the reserved set. * * @param value the string to be encoded * @return the encoded string diff --git a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java index 14c3238f7..6c432e672 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java +++ b/google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java @@ -124,10 +124,10 @@ public static void parse(String content, Object data, boolean decodeEnabled) { * @param data data key name/value pairs * @since 1.14 */ - public static void parse(Reader reader, Object data) throws IOException { - parse(reader, data, true); - } - + public static void parse(Reader reader, Object data) throws IOException { + parse(reader, data, true); + } + /** * Parses the given URL-encoded content into the given data object of data key name/value pairs, * including support for repeating data key names. @@ -139,10 +139,9 @@ public static void parse(Reader reader, Object data) throws IOException { * They are parsed the same as "primitive" fields, except that the generic type parameter of the * collection is used as the {@link Class} parameter. * - *

If there is no declared field for an input parameter name, it is ignored unless the - * input {@code data} parameter is a {@link Map}. If it is a map, the parameter value is - * stored either as a string, or as a {@link ArrayList}<String> in the case of repeated - * parameters. + *

If there is no declared field for an input parameter name, it is ignored unless the input + * {@code data} parameter is a {@link Map}. If it is a map, the parameter value is stored either + * as a string, or as a {@link ArrayList}<String> in the case of repeated parameters. * * @param reader URL-encoded reader * @param data data key name/value pairs @@ -168,9 +167,13 @@ public static void parse(Reader reader, Object data, boolean decodeEnabled) thro // falls through case '&': // parse name/value pair - String name = decodeEnabled ? CharEscapers.decodeUri(nameWriter.toString()) : nameWriter.toString(); + String name = + decodeEnabled ? CharEscapers.decodeUri(nameWriter.toString()) : nameWriter.toString(); if (name.length() != 0) { - String stringValue = decodeEnabled ? CharEscapers.decodeUri(valueWriter.toString()) : valueWriter.toString(); + String stringValue = + decodeEnabled + ? CharEscapers.decodeUri(valueWriter.toString()) + : valueWriter.toString(); // get the field from the type information FieldInfo fieldInfo = classInfo.getFieldInfo(name); if (fieldInfo != null) { diff --git a/google-http-client/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java b/google-http-client/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java index ce5e59d51..890bdf2f2 100644 --- a/google-http-client/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java +++ b/google-http-client/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java @@ -74,8 +74,8 @@ * * @since 1.0 * @author Yaniv Inbar - * @deprecated Please use com.google.api.client.http.apache.v2.ApacheHttpTransport provided by - * the com.google.http-client:google-http-client-apache-v2 artifact. + * @deprecated Please use com.google.api.client.http.apache.v2.ApacheHttpTransport provided by the + * com.google.http-client:google-http-client-apache-v2 artifact. */ @Deprecated public final class ApacheHttpTransport extends HttpTransport { diff --git a/google-http-client/src/main/java/com/google/api/client/json/JsonString.java b/google-http-client/src/main/java/com/google/api/client/json/JsonString.java index 68b3b2f9c..2d0a2ba70 100644 --- a/google-http-client/src/main/java/com/google/api/client/json/JsonString.java +++ b/google-http-client/src/main/java/com/google/api/client/json/JsonString.java @@ -40,8 +40,8 @@ * * * - *

However, if instead the JSON content uses a JSON String to store the value, one needs to use the - * {@link JsonString} annotation. For example: + *

However, if instead the JSON content uses a JSON String to store the value, one needs to use + * the {@link JsonString} annotation. For example: * *

  * 
diff --git a/google-http-client/src/main/java/com/google/api/client/json/webtoken/DerEncoder.java b/google-http-client/src/main/java/com/google/api/client/json/webtoken/DerEncoder.java
index ce7c42f12..7d3b465b4 100644
--- a/google-http-client/src/main/java/com/google/api/client/json/webtoken/DerEncoder.java
+++ b/google-http-client/src/main/java/com/google/api/client/json/webtoken/DerEncoder.java
@@ -17,16 +17,14 @@
 package com.google.api.client.json.webtoken;
 
 import com.google.api.client.util.Preconditions;
-
 import java.math.BigInteger;
 import java.util.Arrays;
 
 /**
  * Utilities for re-encoding a signature byte array with DER encoding.
  *
- * 

Note: that this is not a general purpose encoder and currently only - * handles 512 bit signatures. ES256 verification algorithms expect the - * signature bytes in DER encoding. + *

Note: that this is not a general purpose encoder and currently only handles 512 bit + * signatures. ES256 verification algorithms expect the signature bytes in DER encoding. */ public class DerEncoder { private static byte DER_TAG_SIGNATURE_OBJECT = 0x30; diff --git a/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebSignature.java b/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebSignature.java index aa21dbe2e..4886b7927 100644 --- a/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebSignature.java +++ b/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebSignature.java @@ -23,14 +23,12 @@ import com.google.api.client.util.StringUtils; import java.io.ByteArrayInputStream; import java.io.IOException; -import java.math.BigInteger; import java.security.GeneralSecurityException; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.PublicKey; -import java.security.Signature; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; @@ -78,8 +76,7 @@ public JsonWebSignature( } /** - * Header as specified in - * Reserved + * Header as specified in Reserved * Header Parameter Names. */ public static class Header extends JsonWebToken.Header { @@ -305,8 +302,8 @@ public Header setX509Certificates(List x509Certificates) { } /** - * Returns an array listing the header parameter names that define extensions used in - * the JWS header that MUST be understood and processed or {@code null} for none. + * Returns an array listing the header parameter names that define extensions used in the JWS + * header that MUST be understood and processed or {@code null} for none. * * @since 1.16 */ @@ -318,8 +315,8 @@ public final List getCritical() { } /** - * Sets the header parameter names that define extensions used in the - * JWS header that MUST be understood and processed or {@code null} for none. + * Sets the header parameter names that define extensions used in the JWS header that MUST be + * understood and processed or {@code null} for none. * *

Overriding is only supported for the purpose of calling the super implementation and * changing the return type, but nothing else. @@ -350,8 +347,8 @@ public Header getHeader() { /** * Verifies the signature of the content. * - *

Currently only {@code "RS256"} and {@code "ES256"} algorithms are verified, but others may be added in the - * future. For any other algorithm it returns {@code false}. + *

Currently only {@code "RS256"} and {@code "ES256"} algorithms are verified, but others may + * be added in the future. For any other algorithm it returns {@code false}. * * @param publicKey public key * @return whether the algorithm is recognized and it is verified @@ -360,9 +357,17 @@ public Header getHeader() { public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurityException { String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { - return SecurityUtils.verify(SecurityUtils.getSha256WithRsaSignatureAlgorithm(), publicKey, signatureBytes, signedContentBytes); + return SecurityUtils.verify( + SecurityUtils.getSha256WithRsaSignatureAlgorithm(), + publicKey, + signatureBytes, + signedContentBytes); } else if ("ES256".equals(algorithm)) { - return SecurityUtils.verify(SecurityUtils.getEs256SignatureAlgorithm(), publicKey, DerEncoder.encode(signatureBytes), signedContentBytes); + return SecurityUtils.verify( + SecurityUtils.getEs256SignatureAlgorithm(), + publicKey, + DerEncoder.encode(signatureBytes), + signedContentBytes); } else { return false; } @@ -372,8 +377,8 @@ public final boolean verifySignature(PublicKey publicKey) throws GeneralSecurity * {@link Beta}
* Verifies the signature of the content using the certificate chain embedded in the signature. * - *

Currently only {@code "RS256"} and {@code "ES256"} algorithms are verified, but others may be added in the - * future. For any other algorithm it returns {@code null}. + *

Currently only {@code "RS256"} and {@code "ES256"} algorithms are verified, but others may + * be added in the future. For any other algorithm it returns {@code null}. * *

The leaf certificate of the certificate chain must be an SSL server certificate. * @@ -392,9 +397,19 @@ public final X509Certificate verifySignature(X509TrustManager trustManager) } String algorithm = getHeader().getAlgorithm(); if ("RS256".equals(algorithm)) { - return SecurityUtils.verify(SecurityUtils.getSha256WithRsaSignatureAlgorithm(), trustManager, x509Certificates, signatureBytes, signedContentBytes); + return SecurityUtils.verify( + SecurityUtils.getSha256WithRsaSignatureAlgorithm(), + trustManager, + x509Certificates, + signatureBytes, + signedContentBytes); } else if ("ES256".equals(algorithm)) { - return SecurityUtils.verify(SecurityUtils.getEs256SignatureAlgorithm(), trustManager, x509Certificates, DerEncoder.encode(signatureBytes), signedContentBytes); + return SecurityUtils.verify( + SecurityUtils.getEs256SignatureAlgorithm(), + trustManager, + x509Certificates, + DerEncoder.encode(signatureBytes), + signedContentBytes); } else { return null; } diff --git a/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebToken.java b/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebToken.java index f68450190..bfcf63fe9 100644 --- a/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebToken.java +++ b/google-http-client/src/main/java/com/google/api/client/json/webtoken/JsonWebToken.java @@ -47,8 +47,7 @@ public JsonWebToken(Header header, Payload payload) { } /** - * Header as specified in - * JWT Header. + * Header as specified in JWT Header. */ public static class Header extends GenericJson { @@ -115,9 +114,8 @@ public Header clone() { } /** - * Payload as specified in - * Reserved Claim - * Names. + * Payload as specified in Reserved + * Claim Names. */ public static class Payload extends GenericJson { diff --git a/google-http-client/src/main/java/com/google/api/client/util/PemReader.java b/google-http-client/src/main/java/com/google/api/client/util/PemReader.java index 607d80de0..a1f06a3bc 100644 --- a/google-http-client/src/main/java/com/google/api/client/util/PemReader.java +++ b/google-http-client/src/main/java/com/google/api/client/util/PemReader.java @@ -36,7 +36,9 @@ * *

Limitations: * - *