@@ -147,30 +147,24 @@ private String determineEndpoint(Builder builder) {
147
147
* from the google-auth-library. If the HttpRequestInitializer is not used, the configured
148
148
* Universe Domain is validated against the Google Default Universe (GDU): `googleapis.com`.
149
149
*
150
- * @throws IllegalStateException if the configured Universe Domain does not match the Universe
151
- * Domain in the Credentials
150
+ * @throws IOException if the configured Universe Domain does not match the Universe Domain in the
151
+ * Credentials or there is an error reading the Universe Domain from the credentials
152
152
*/
153
- public void validateUniverseDomain () {
153
+ public void validateUniverseDomain () throws IOException {
154
154
String expectedUniverseDomain ;
155
- try {
156
- if (!(httpRequestInitializer instanceof HttpCredentialsAdapter )) {
157
- expectedUniverseDomain = Credentials .GOOGLE_DEFAULT_UNIVERSE ;
158
- } else {
159
- Credentials credentials =
160
- ((HttpCredentialsAdapter ) httpRequestInitializer ).getCredentials ();
161
- expectedUniverseDomain = credentials .getUniverseDomain ();
162
- }
163
- if (!expectedUniverseDomain .equals (getUniverseDomain ())) {
164
- throw new IllegalStateException (
165
- String .format (
166
- "The configured universe domain (%s) does not match the universe domain found"
167
- + " in the credentials (%s). If you haven't configured the universe domain"
168
- + " explicitly, `googleapis.com` is the default." ,
169
- getUniverseDomain (), expectedUniverseDomain ));
170
- }
171
- } catch (IOException e ) {
172
- throw new IllegalStateException (
173
- "Unable to retrieve the Universe Domain from the Credentials." , e );
155
+ if (!(httpRequestInitializer instanceof HttpCredentialsAdapter )) {
156
+ expectedUniverseDomain = Credentials .GOOGLE_DEFAULT_UNIVERSE ;
157
+ } else {
158
+ Credentials credentials = ((HttpCredentialsAdapter ) httpRequestInitializer ).getCredentials ();
159
+ expectedUniverseDomain = credentials .getUniverseDomain ();
160
+ }
161
+ if (!expectedUniverseDomain .equals (getUniverseDomain ())) {
162
+ throw new IOException (
163
+ String .format (
164
+ "The configured universe domain (%s) does not match the universe domain found"
165
+ + " in the credentials (%s). If you haven't configured the universe domain"
166
+ + " explicitly, `googleapis.com` is the default." ,
167
+ getUniverseDomain (), expectedUniverseDomain ));
174
168
}
175
169
}
176
170
0 commit comments