@@ -88,13 +88,21 @@ default void validatePayload(String payload) {
88
88
}
89
89
90
90
static Connector fromStream (StreamInput in ) throws IOException {
91
- String connectorProtocol = in .readString ();
92
- return MLCommonsClassLoader .initConnector (connectorProtocol , new Object []{connectorProtocol , in }, String .class , StreamInput .class );
91
+ try {
92
+ String connectorProtocol = in .readString ();
93
+ return MLCommonsClassLoader .initConnector (connectorProtocol , new Object []{connectorProtocol , in }, String .class , StreamInput .class );
94
+ } catch (IllegalArgumentException illegalArgumentException ) {
95
+ throw illegalArgumentException ;
96
+ }
93
97
}
94
98
95
99
static Connector createConnector (XContentBuilder builder , String connectorProtocol ) throws IOException {
96
- String jsonStr = builder .toString ();
97
- return createConnector (jsonStr , connectorProtocol );
100
+ try {
101
+ String jsonStr = builder .toString ();
102
+ return createConnector (jsonStr , connectorProtocol );
103
+ } catch (IllegalArgumentException illegalArgumentException ) {
104
+ throw illegalArgumentException ;
105
+ }
98
106
}
99
107
100
108
static Connector createConnector (XContentParser parser ) throws IOException {
@@ -118,7 +126,12 @@ private static Connector createConnector(String jsonStr, String connectorProtoco
118
126
throw new IllegalArgumentException ("connector protocol is null" );
119
127
}
120
128
return MLCommonsClassLoader .initConnector (connectorProtocol , new Object []{connectorProtocol , connectorParser }, String .class , XContentParser .class );
121
- }
129
+ } catch (Exception ex ) {
130
+ if (ex instanceof IllegalArgumentException ) {
131
+ throw ex ;
132
+ }
133
+ return null ;
134
+ }
122
135
}
123
136
124
137
default void validateConnectorURL (List <String > urlRegexes ) {
0 commit comments