diff --git a/pom.xml b/pom.xml index d06eeca..d1df7e0 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,11 @@ 12.1.8 + + org.slf4j + slf4j-simple + 2.0.17 + junit junit diff --git a/src/org/spdx/crossref/Live.java b/src/org/spdx/crossref/Live.java index ac07608..472dd5b 100644 --- a/src/org/spdx/crossref/Live.java +++ b/src/org/spdx/crossref/Live.java @@ -51,14 +51,15 @@ public static boolean urlLinkExists(String URLName){ // fake request coming from browser con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"); con.setRequestMethod("HEAD"); - con.setConnectTimeout(8500); + con.setConnectTimeout(30000); + con.setReadTimeout(30000); int responseCode = con.getResponseCode(); return (responseCode == HttpURLConnection.HTTP_OK || responseCode == HttpURLConnection.HTTP_NOT_MODIFIED || responseCode == HttpURLConnection.HTTP_MOVED_PERM || responseCode == HttpURLConnection.HTTP_MOVED_TEMP); } catch (UnknownHostException e) { return false; } catch (Exception e) { - logger.warn("Failed checking live status.",e.getMessage()); + logger.warn("Failed checking live status for URL {}: {}", URLName, e.getMessage()); return false; } } diff --git a/src/org/spdx/crossref/Match.java b/src/org/spdx/crossref/Match.java index d2d96b1..27cbdd7 100644 --- a/src/org/spdx/crossref/Match.java +++ b/src/org/spdx/crossref/Match.java @@ -46,11 +46,12 @@ public Match(String url, SpdxListedLicense license) { */ public static String checkMatch(String url, SpdxListedLicense license){ try { - Document doc = Jsoup.connect(url).get(); + Document doc = Jsoup.connect(url).timeout(30000).get(); String bodyText = doc.body().text(); return String.valueOf(LicenseCompareHelper.isStandardLicenseWithinText(bodyText, license)); } catch (IOException e) { - logger.warn("IO exception comparing license text for license ID "+license.getLicenseId()+" and URL "+url); + logger.warn("IO exception comparing license text for license ID {} and URL {}: {}", url, + license.getLicenseId(), e.getMessage()); return String.valueOf(false); } } diff --git a/src/org/spdx/licensexml/XmlLicenseProviderWithCrossRefDetails.java b/src/org/spdx/licensexml/XmlLicenseProviderWithCrossRefDetails.java index 1b71ed9..d19b822 100644 --- a/src/org/spdx/licensexml/XmlLicenseProviderWithCrossRefDetails.java +++ b/src/org/spdx/licensexml/XmlLicenseProviderWithCrossRefDetails.java @@ -94,7 +94,7 @@ public synchronized ListedLicenseContainer next() { ListedLicenseContainer retval = readyLicense.getKey(); try { - for (CrossRef crossRef:readyLicense.getValue().get(2, TimeUnit.MINUTES)) { + for (CrossRef crossRef:readyLicense.getValue().get(5, TimeUnit.MINUTES)) { retval.getV2ListedLicense().getCrossRef().add(crossRef); }