Skip to content

Commit c92e2dc

Browse files
committed
Reverting Exception instead of IOException in HttpRequest and HttpResponseException.
1 parent b99e5ed commit c92e2dc

40 files changed

+253
-392
lines changed

google-http-client-appengine/src/main/java/com/google/api/client/extensions/appengine/http/UrlFetchRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public void setTimeout(int connectTimeout, int readTimeout) {
5757
}
5858

5959
@Override
60-
public LowLevelHttpResponse execute() throws Exception {
60+
public LowLevelHttpResponse execute() throws IOException {
6161
// write content
6262
if (content != null) {
6363
String contentType = content.getType();

google-http-client-appengine/src/main/java/com/google/api/client/extensions/appengine/http/urlfetch/UrlFetchRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public void setTimeout(int connectTimeout, int readTimeout) {
5858
}
5959

6060
@Override
61-
public LowLevelHttpResponse execute() throws Exception {
61+
public LowLevelHttpResponse execute() throws IOException {
6262
// write content
6363
if (content != null) {
6464
String contentType = content.getType();

google-http-client/src/main/java/com/google/api/client/http/AbstractHttpContent.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.google.common.base.Charsets;
1818

19+
import java.io.IOException;
1920
import java.io.OutputStream;
2021
import java.nio.charset.Charset;
2122

@@ -62,13 +63,8 @@ public String getEncoding() {
6263
/**
6364
* Default implementation calls {@link #computeLength()} once and caches it for future
6465
* invocations, but subclasses may override.
65-
*
66-
* <p>
67-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
68-
* an {@link java.io.IOException}.
69-
* </p>
7066
*/
71-
public long getLength() throws Exception {
67+
public long getLength() throws IOException {
7268
if (computedLength == -1) {
7369
computedLength = computeLength();
7470
}
@@ -122,13 +118,8 @@ public String getType() {
122118
* but only retains the count of bytes. If {@link #retrySupported()} is {@code false}, it will
123119
* instead return {@code -1}.
124120
* </p>
125-
*
126-
* <p>
127-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
128-
* an {@link java.io.IOException}.
129-
* </p>
130121
*/
131-
protected long computeLength() throws Exception {
122+
protected long computeLength() throws IOException {
132123
if (!retrySupported()) {
133124
return -1;
134125
}

google-http-client/src/main/java/com/google/api/client/http/BackOffPolicy.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.api.client.http;
1616

17+
import java.io.IOException;
1718

1819
/**
1920
* Strategy interface to control back off between retry attempts.
@@ -60,12 +61,12 @@ public interface BackOffPolicy {
6061
* </pre>
6162
*
6263
* <p>
63-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
64-
* an {@link java.io.IOException}.
64+
* Upgrade warning: {@link #getNextBackOffMillis} now throws an {@link IOException}, it was not
65+
* thrown prior to 1.9.
6566
* </p>
6667
*
6768
* @return the number of milliseconds to wait when backing off requests, or {@link #STOP} if no
6869
* more retries should be made
6970
*/
70-
public long getNextBackOffMillis() throws Exception;
71+
public long getNextBackOffMillis() throws IOException;
7172
}

google-http-client/src/main/java/com/google/api/client/http/ExponentialBackOffPolicy.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import com.google.common.base.Preconditions;
1818

19+
import java.io.IOException;
20+
1921
/**
2022
* Implementation of {@link BackOffPolicy} that increases the back off period for each retry attempt
2123
* using a randomization function that grows exponentially.
@@ -232,14 +234,14 @@ public final void reset() {
232234
* </p>
233235
*
234236
* <p>
235-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
236-
* an {@link java.io.IOException}.
237+
* Upgrade warning: {@link #getNextBackOffMillis} now throws an {@link IOException}, it was not
238+
* thrown prior to 1.9.
237239
* </p>
238240
*
239241
* @return the number of milliseconds to wait when backing off requests, or {@link #STOP} if no
240242
* more retries should be made
241243
*/
242-
public long getNextBackOffMillis() throws Exception {
244+
public long getNextBackOffMillis() throws IOException {
243245
// Make sure we have not gone over the maximum elapsed time.
244246
if (getElapsedTimeMillis() > maxElapsedTimeMillis) {
245247
return STOP;

google-http-client/src/main/java/com/google/api/client/http/GZipContent.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.api.client.http;
1616

17+
import java.io.IOException;
1718
import java.io.OutputStream;
1819
import java.util.zip.GZIPOutputStream;
1920

@@ -47,13 +48,8 @@ final class GZipContent extends AbstractHttpContent {
4748
* href='http://code.google.com/p/google-http-java-client/issues/detail?id=61'>61</a> for more
4849
* information.
4950
* </p>
50-
*
51-
* <p>
52-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
53-
* an {@link java.io.IOException}.
54-
* </p>
5551
*/
56-
public void writeTo(OutputStream out) throws Exception {
52+
public void writeTo(OutputStream out) throws IOException {
5753
GZIPOutputStream zipper = new GZIPOutputStream(out);
5854
httpContent.writeTo(zipper);
5955
zipper.close();

google-http-client/src/main/java/com/google/api/client/http/HttpContent.java

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.api.client.http;
1616

17+
import java.io.IOException;
1718
import java.io.OutputStream;
1819

1920
/**
@@ -28,15 +29,8 @@
2829
*/
2930
public interface HttpContent {
3031

31-
/**
32-
* Returns the content length or less than zero if not known.
33-
*
34-
* <p>
35-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
36-
* an {@link java.io.IOException}.
37-
* </p>
38-
*/
39-
long getLength() throws Exception;
32+
/** Returns the content length or less than zero if not known. */
33+
long getLength() throws IOException;
4034

4135
/**
4236
* Returns the content encoding (for example {@code "gzip"}) or {@code null} for none.
@@ -54,13 +48,8 @@ public interface HttpContent {
5448
* should not assume whether or not the output stream has been closed. Implementations that do not
5549
* close the output stream should flush it at the end of the method.
5650
* </p>
57-
*
58-
* <p>
59-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
60-
* an {@link java.io.IOException}.
61-
* </p>
6251
*/
63-
void writeTo(OutputStream out) throws Exception;
52+
void writeTo(OutputStream out) throws IOException;
6453

6554
/**
6655
* Returns whether or not retry is supported on this content type.

google-http-client/src/main/java/com/google/api/client/http/HttpExecuteInterceptor.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.api.client.http;
1616

17+
import java.io.IOException;
1718

1819
/**
1920
* HTTP request execute interceptor to intercept the start of {@link HttpRequest#execute()} before
@@ -25,7 +26,7 @@
2526
*
2627
* <pre>
2728
public class OAuthSigner implements HttpExecuteInterceptor {
28-
public void intercept(HttpRequest request) throws Exception {
29+
public void intercept(HttpRequest request) throws IOException {
2930
// sign request...
3031
}
3132
}
@@ -56,7 +57,7 @@ public static HttpRequestFactory createRequestFactory(HttpTransport transport) {
5657
return transport.createRequestFactory(new HttpRequestInitializer() {
5758
public void initialize(HttpRequest request) {
5859
request.interceptor = new HttpExecuteInterceptor() {
59-
public void intercept(HttpRequest request) throws Exception {
60+
public void intercept(HttpRequest request) throws IOException {
6061
signer.intercept(request);
6162
}
6263
};
@@ -74,13 +75,6 @@ public void intercept(HttpRequest request) throws Exception {
7475
*/
7576
public interface HttpExecuteInterceptor {
7677

77-
/**
78-
* Invoked at the start of {@link HttpRequest#execute()} before executing the HTTP request.
79-
*
80-
* <p>
81-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
82-
* an {@link java.io.IOException}.
83-
* </p>
84-
*/
85-
void intercept(HttpRequest request) throws Exception;
78+
/** Invoked at the start of {@link HttpRequest#execute()} before executing the HTTP request. */
79+
void intercept(HttpRequest request) throws IOException;
8680
}

google-http-client/src/main/java/com/google/api/client/http/HttpHeaders.java

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ private static void addHeader(Logger logger,
624624
LowLevelHttpRequest lowLevelHttpRequest,
625625
String name,
626626
Object value,
627-
Writer writer) throws Exception {
627+
Writer writer) throws IOException {
628628
// ignore nulls
629629
if (value == null || Data.isNull(value)) {
630630
return;
@@ -658,11 +658,6 @@ private static void addHeader(Logger logger,
658658
/**
659659
* Serializes headers to an @{link LowLevelHttpRequest}.
660660
*
661-
* <p>
662-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
663-
* an {@link IOException}.
664-
* </p>
665-
*
666661
* @param headers HTTP headers
667662
* @param logbuf log buffer or {@code null} for none
668663
* @param logger logger or {@code null} for none. Logger must be specified if log buffer is
@@ -673,18 +668,13 @@ private static void addHeader(Logger logger,
673668
* @since 1.9
674669
*/
675670
public static void serializeHeaders(HttpHeaders headers, StringBuilder logbuf, Logger logger,
676-
LowLevelHttpRequest lowLevelHttpRequest) throws Exception {
671+
LowLevelHttpRequest lowLevelHttpRequest) throws IOException {
677672
serializeHeaders(headers, logbuf, logger, lowLevelHttpRequest, null);
678673
}
679674

680675
/**
681676
* Serializes headers to an {@link Writer} for Multi-part requests.
682677
*
683-
* <p>
684-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
685-
* an {@link IOException}.
686-
* </p>
687-
*
688678
* @param headers HTTP headers
689679
* @param logbuf log buffer or {@code null} for none
690680
* @param logger logger or {@code null} for none. Logger must be specified if log buffer is
@@ -694,12 +684,12 @@ public static void serializeHeaders(HttpHeaders headers, StringBuilder logbuf, L
694684
* @since 1.9
695685
*/
696686
public static void serializeHeadersForMultipartRequests(
697-
HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer) throws Exception {
687+
HttpHeaders headers, StringBuilder logbuf, Logger logger, Writer writer) throws IOException {
698688
serializeHeaders(headers, logbuf, logger, null, writer);
699689
}
700690

701691
private static void serializeHeaders(HttpHeaders headers, StringBuilder logbuf, Logger logger,
702-
LowLevelHttpRequest lowLevelHttpRequest, Writer writer) throws Exception {
692+
LowLevelHttpRequest lowLevelHttpRequest, Writer writer) throws IOException {
703693
HashSet<String> headerNames = new HashSet<String>();
704694
for (Map.Entry<String, Object> headerEntry : headers.entrySet()) {
705695
String name = headerEntry.getKey();
@@ -775,11 +765,6 @@ public LowLevelHttpResponse execute() throws IOException {
775765
/**
776766
* Puts all headers of the {@link HttpHeaders} object into this {@link HttpHeaders} object.
777767
*
778-
* <p>
779-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
780-
* an {@link IOException}.
781-
* </p>
782-
*
783768
* @param headers {@link HttpHeaders} from where the headers are taken
784769
* @since 1.10
785770
*/
@@ -788,7 +773,7 @@ public final void fromHttpHeaders(HttpHeaders headers) {
788773
ParseHeaderState state = new ParseHeaderState(this, null);
789774
serializeHeaders(headers, null, null, new HeaderParsingFakeLevelHttpRequest(this, state));
790775
state.finish();
791-
} catch (Exception ex) {
776+
} catch (IOException ex) {
792777
// Should never occur as we are dealing with a FakeLowLevelHttpRequest
793778
throw new IllegalStateException(ex);
794779
}

google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -763,18 +763,13 @@ public HttpRequest setRetryOnExecuteIOException(boolean retryOnExecuteIOExceptio
763763
}
764764
* </pre>
765765
*
766-
* <p>
767-
* Upgrade warning: this method now throws an {@link Exception}. In prior version 1.10 it threw
768-
* an {@link IOException}.
769-
* </p>
770-
*
771766
* @return HTTP response for an HTTP success response (or HTTP error response if
772767
* {@link #getThrowExceptionOnExecuteError()} is {@code false})
773768
* @throws HttpResponseException for an HTTP error response (only if
774769
* {@link #getThrowExceptionOnExecuteError()} is {@code true})
775770
* @see HttpResponse#isSuccessStatusCode()
776771
*/
777-
public HttpResponse execute() throws Exception {
772+
public HttpResponse execute() throws IOException {
778773
boolean retrySupported = false;
779774
Preconditions.checkArgument(numRetries >= 0);
780775
int retriesRemaining = numRetries;

0 commit comments

Comments
 (0)