@@ -80,31 +80,46 @@ public URI newURI(String s) throws URISyntaxException {
80
80
public URI newURI (String scheme ,
81
81
String userInfo , String host , int port ,
82
82
String path , String query , String fragment )
83
- throws URISyntaxException {
83
+ throws URISyntaxException {
84
84
if (!isAccountIdUri (host )) {
85
85
log .trace (() -> "skipping cache for host" + host );
86
86
return new URI (scheme , userInfo , host , port , path , query , fragment );
87
87
}
88
- HostConstructorArgs key = new HostConstructorArgs (scheme , userInfo , host , port , path , query , fragment );
89
- boolean containsK = cache .contains (key );
90
- URI uri = cache .get (key );
91
- logCacheUsage (containsK , uri );
92
- return uri ;
88
+ try {
89
+ HostConstructorArgs key = new HostConstructorArgs (scheme , userInfo , host , port , path , query , fragment );
90
+ boolean containsK = cache .contains (key );
91
+ URI uri = cache .get (key );
92
+ logCacheUsage (containsK , uri );
93
+ return uri ;
94
+ } catch (IllegalArgumentException e ) {
95
+ if (e .getCause () instanceof URISyntaxException ) {
96
+ throw (URISyntaxException ) e .getCause ();
97
+ }
98
+ throw e ;
99
+ }
100
+
93
101
}
94
102
95
103
public URI newURI (String scheme ,
96
104
String authority ,
97
105
String path , String query , String fragment )
98
- throws URISyntaxException {
106
+ throws URISyntaxException {
99
107
if (!isAccountIdUri (authority )) {
100
108
log .trace (() -> "skipping cache for authority" + authority );
101
109
return new URI (scheme , authority , path , query , fragment );
102
110
}
103
- AuthorityConstructorArgs key = new AuthorityConstructorArgs (scheme , authority , path , query , fragment );
104
- boolean containsK = cache .contains (key );
105
- URI uri = cache .get (key );
106
- logCacheUsage (containsK , uri );
107
- return uri ;
111
+ try {
112
+ AuthorityConstructorArgs key = new AuthorityConstructorArgs (scheme , authority , path , query , fragment );
113
+ boolean containsK = cache .contains (key );
114
+ URI uri = cache .get (key );
115
+ logCacheUsage (containsK , uri );
116
+ return uri ;
117
+ } catch (IllegalArgumentException e ) {
118
+ if (e .getCause () instanceof URISyntaxException ) {
119
+ throw (URISyntaxException ) e .getCause ();
120
+ }
121
+ throw e ;
122
+ }
108
123
}
109
124
110
125
/*
0 commit comments