File tree 3 files changed +32
-1
lines changed
plugins/vulnerable-chain-finder/src/main/java/eu/f4sten/vulchainfinder
3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change 25
25
import eu .f4sten .infra .kafka .MessageGenerator ;
26
26
import eu .f4sten .pomanalyzer .data .MavenId ;
27
27
import eu .f4sten .pomanalyzer .data .PomAnalysisResult ;
28
+ import eu .f4sten .vulchainfinder .exceptions .RestApiError ;
28
29
import eu .f4sten .vulchainfinder .utils .DatabaseUtils ;
29
30
import eu .f4sten .vulchainfinder .utils .ImpactPropagator ;
30
31
import eu .f4sten .vulchainfinder .utils .RestAPIDependencyResolver ;
@@ -155,6 +156,9 @@ public static MavenId extractMavenIdFrom(final PomAnalysisResult pomAnalysisResu
155
156
private void runOrPublishErr (final Runnable r ) {
156
157
try {
157
158
r .run ();
159
+ } catch (RestApiError e ) {
160
+ LOG .error ("Forced to stop the plug-in as the REST API is unavailable" , e );
161
+ throw e ;
158
162
} catch (Exception e ) {
159
163
LOG .warn ("Execution failed for input: {}" , curId , e );
160
164
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright 2022 Delft University of Technology
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package eu .f4sten .vulchainfinder .exceptions ;
18
+
19
+ /**
20
+ * A custom exception for Rest API-related exception to stop the plug-in's container. This error is unrecoverable.
21
+ */
22
+ public class RestApiError extends Error {
23
+ public RestApiError (String errorMsg , Throwable err ) {
24
+ super (errorMsg , err );
25
+ }
26
+ }
Original file line number Diff line number Diff line change 1
1
package eu .f4sten .vulchainfinder .utils ;
2
2
3
3
import eu .f4sten .pomanalyzer .data .MavenId ;
4
+ import eu .f4sten .vulchainfinder .exceptions .RestApiError ;
4
5
import eu .fasten .core .data .metadatadb .codegen .tables .Dependencies ;
5
6
import eu .fasten .core .data .metadatadb .codegen .tables .PackageVersions ;
6
7
import java .io .IOException ;
@@ -81,7 +82,7 @@ public HttpResponse<String> sendOrThrow(final HttpRequest request) {
81
82
exception = e ;
82
83
}
83
84
if (exception != null || response == null || isNotOK (response )) {
84
- throw new RuntimeException ("Problem requesting Rest API." , exception );
85
+ throw new RestApiError ("Problem requesting Rest API." , exception );
85
86
}
86
87
87
88
return response ;
You can’t perform that action at this time.
0 commit comments