@@ -148,40 +148,45 @@ protected void analyzeDependency(final Dependency dependency, final Engine engin
148148 try {
149149 requestDelay ();
150150 reports = requestReports (engine .getDependencies ());
151- } catch (TransportException ex ) {
151+ } catch (SocketTimeoutException e ) {
152+ final boolean warnOnly = getSettings ().getBoolean (Settings .KEYS .ANALYZER_OSSINDEX_WARN_ONLY_ON_REMOTE_ERRORS , false );
153+ this .setEnabled (false );
154+ if (warnOnly ) {
155+ LOG .warn ("OSS Index socket timeout, disabling the analyzer" , e );
156+ } else {
157+ LOG .debug ("OSS Index socket timeout" , e );
158+ throw new AnalysisException ("Failed to establish socket to OSS Index" , e );
159+ }
160+ } catch (Exception ex ) {
152161 final String message = ex .getMessage ();
153162 final boolean warnOnly = getSettings ().getBoolean (Settings .KEYS .ANALYZER_OSSINDEX_WARN_ONLY_ON_REMOTE_ERRORS , false );
154163 this .setEnabled (false );
155- if (StringUtils .endsWith (message , "401" )) {
156- LOG .error ("Invalid credentials for the OSS Index, disabling the analyzer" );
157- throw new AnalysisException ("Invalid credentials provided for OSS Index" , ex );
158- } else if (StringUtils .endsWith (message , "403" )) {
159- LOG .error ("OSS Index access forbidden, disabling the analyzer" );
160- throw new AnalysisException ("OSS Index access forbidden" , ex );
161- } else if (StringUtils .endsWith (message , "429" )) {
164+ if (StringUtils .contains (message , "401" )) {
165+ if (warnOnly ) {
166+ LOG .warn ("Invalid credentials for the OSS Index, disabling the analyzer" );
167+ } else {
168+ LOG .error ("Invalid credentials for the OSS Index, disabling the analyzer" );
169+ throw new AnalysisException ("Invalid credentials provided for OSS Index" , ex );
170+ }
171+ } else if (StringUtils .contains (message , "403" )) {
172+ if (warnOnly ) {
173+ LOG .warn ("OSS Index access forbidden, disabling the analyzer" );
174+ } else {
175+ LOG .error ("OSS Index access forbidden, disabling the analyzer" );
176+ throw new AnalysisException ("OSS Index access forbidden" , ex );
177+ }
178+ } else if (StringUtils .contains (message , "429" )) {
162179 if (warnOnly ) {
163180 LOG .warn ("OSS Index rate limit exceeded, disabling the analyzer" , ex );
164181 } else {
165182 throw new AnalysisException ("OSS Index rate limit exceeded, disabling the analyzer" , ex );
166183 }
167184 } else if (warnOnly ) {
168- LOG .warn ("Error requesting component reports, disabling the analyzer" , ex );
185+ LOG .warn ("Error requesting component reports, disabling the analyzer. " + ex . getMessage () , ex );
169186 } else {
170187 LOG .debug ("Error requesting component reports, disabling the analyzer" , ex );
171- throw new AnalysisException ("Failed to request component-reports" , ex );
172- }
173- } catch (SocketTimeoutException e ) {
174- final boolean warnOnly = getSettings ().getBoolean (Settings .KEYS .ANALYZER_OSSINDEX_WARN_ONLY_ON_REMOTE_ERRORS , false );
175- this .setEnabled (false );
176- if (warnOnly ) {
177- LOG .warn ("OSS Index socket timeout, disabling the analyzer" , e );
178- } else {
179- LOG .debug ("OSS Index socket timeout" , e );
180- throw new AnalysisException ("Failed to establish socket to OSS Index" , e );
188+ throw new AnalysisException ("Failed to request component-reports. " + ex .getMessage (), ex );
181189 }
182- } catch (Exception e ) {
183- LOG .debug ("Error requesting component reports" , e );
184- throw new AnalysisException ("Failed to request component-reports" , e );
185190 }
186191 }
187192
0 commit comments