Skip to content

Commit 882d8a3

Browse files
committed
http: Add a default instance to UrlFetchTransport
https://codereview.appspot.com/12666043/
1 parent 0597b74 commit 882d8a3

File tree

1 file changed

+18
-0
lines changed
  • google-http-client-appengine/src/main/java/com/google/api/client/extensions/appengine/http

1 file changed

+18
-0
lines changed

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

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

1717
import com.google.api.client.http.HttpMethods;
1818
import com.google.api.client.http.HttpTransport;
19+
import com.google.api.client.util.Beta;
1920
import com.google.api.client.util.Preconditions;
2021
import com.google.appengine.api.urlfetch.FetchOptions;
2122
import com.google.appengine.api.urlfetch.HTTPMethod;
@@ -88,6 +89,23 @@ public UrlFetchTransport() {
8889
certificateValidationBehavior = builder.certificateValidationBehavior;
8990
}
9091

92+
/**
93+
* {@link Beta} <br/>
94+
* Returns a global thread-safe instance.
95+
*
96+
* @since 1.17
97+
*/
98+
@Beta
99+
public static UrlFetchTransport getDefaultInstance() {
100+
return InstanceHolder.INSTANCE;
101+
}
102+
103+
/** Holder for the result of {@link #getDefaultInstance()}. */
104+
@Beta
105+
static class InstanceHolder {
106+
static final UrlFetchTransport INSTANCE = new UrlFetchTransport();
107+
}
108+
91109
@Override
92110
public boolean supportsMethod(String method) {
93111
return Arrays.binarySearch(SUPPORTED_METHODS, method) >= 0;

0 commit comments

Comments
 (0)