File tree Expand file tree Collapse file tree
plugins/vulnerable-chain-finder/src/main/java/eu/f4sten/vulchainfinder Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525import eu .f4sten .infra .kafka .MessageGenerator ;
2626import eu .f4sten .pomanalyzer .data .MavenId ;
2727import eu .f4sten .pomanalyzer .data .PomAnalysisResult ;
28+ import eu .f4sten .vulchainfinder .exceptions .RestApiError ;
2829import eu .f4sten .vulchainfinder .utils .DatabaseUtils ;
2930import eu .f4sten .vulchainfinder .utils .ImpactPropagator ;
3031import eu .f4sten .vulchainfinder .utils .RestAPIDependencyResolver ;
@@ -155,6 +156,9 @@ public static MavenId extractMavenIdFrom(final PomAnalysisResult pomAnalysisResu
155156 private void runOrPublishErr (final Runnable r ) {
156157 try {
157158 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 ;
158162 } catch (Exception e ) {
159163 LOG .warn ("Execution failed for input: {}" , curId , e );
160164
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 11package eu .f4sten .vulchainfinder .utils ;
22
33import eu .f4sten .pomanalyzer .data .MavenId ;
4+ import eu .f4sten .vulchainfinder .exceptions .RestApiError ;
45import eu .fasten .core .data .metadatadb .codegen .tables .Dependencies ;
56import eu .fasten .core .data .metadatadb .codegen .tables .PackageVersions ;
67import java .io .IOException ;
@@ -81,7 +82,7 @@ public HttpResponse<String> sendOrThrow(final HttpRequest request) {
8182 exception = e ;
8283 }
8384 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 );
8586 }
8687
8788 return response ;
You can’t perform that action at this time.
0 commit comments