Skip to content

Commit

Permalink
Merge branch 'master' into WINDUPRULE-1041
Browse files Browse the repository at this point in the history
  • Loading branch information
m-brophy authored Jan 16, 2024
2 parents 2e3e703 + f1d379b commit 674c832
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
12 changes: 8 additions & 4 deletions rules/rules-reviewed/openjdk11/openjdk8/java-removals.windup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
As such, the use of `sun.reflect.Reflection` class and particular the `getCallerClass` method should no longer be needed.
Refer to the example changeset linked below.
</message>
<link title="Example changeset" href="https://hg.openjdk.java.net/openjfx/9-dev/rt/rev/70f6fa01a32c"/>
<link title="Example changeset" href="https://github.com/openjdk/jfx/commit/d647521fa83f0cebe9532642ee97ffc4356c8bb3"/>
<link title="JDK-8154203" href="https://bugs.openjdk.org/browse/JDK-8154203"/>
</hint>
</perform>
</rule>
Expand All @@ -64,7 +65,8 @@
`sun.reflect.CallerSensitive` annotation was deprecated in Java 9.
Refer to the example changeset linked below.
</message>
<link title="Example changeset" href="https://hg.openjdk.java.net/openjfx/9-dev/rt/rev/70f6fa01a32c"/>
<link title="Example changeset" href="https://github.com/openjdk/jfx/commit/d647521fa83f0cebe9532642ee97ffc4356c8bb3"/>
<link title="JDK-8154203" href="https://bugs.openjdk.org/browse/JDK-8154203"/>
</hint>
</perform>
</rule>
Expand Down Expand Up @@ -196,7 +198,8 @@

In the long term, please consider using Variable Handles (see the link below)
</message>
<link href="https://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/0a0a0986400e#l2.19" title="Test changes for JDK-8054494"/>
<link href="https://bugs.openjdk.org/browse/JDK-8054494" title="JDK-8054494"/>
<link href="https://github.com/openjdk/jdk/commit/083d9a2b6145a422bad64423675660c94bb32958#diff-12d7d73c9a167ec9451fe5e53373574adc02d9179cab3465e096a07d1aa79fc7" title="Test changes for JDK-8054494"/>
<link href="https://openjdk.java.net/jeps/193" title="Variable Handles"/>
</hint>
</perform>
Expand All @@ -216,7 +219,8 @@
For further examples on how to replace the `BASE64{encoder-decoder}` class with `Base64.{encoder-decoder}` one, refer to the "Code example" link below.
</message>
<link title="java.util.Base64 - Javadoc" href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/Base64.html"/>
<link title="Code example" href="https://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/9078c34437ab"/>
<link title="JDK-8006182" href="https://bugs.openjdk.org/browse/JDK-8006182"/>
<link title="Code example" href="https://github.com/openjdk/jdk/commit/ec9e303630158405d0faaabb74f466f0a376c1fc"/>
<link title="OpenJDK - Original enhancement request" href="https://bugs.openjdk.java.net/browse/JDK-8006182"/>
</hint>
</perform>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@
* This tests all the href attribute in ALL the rules every time the tests are executed (PR and nightly builds)
* Helpful to ensure we have always links that points to something so that links are really helpful for the user
* Optimized with a very basic cache for not checking more than once the same URL
*
* <p>
* The runTestsMatching is available in this test
*
* <p>
* To change the connection timeout use the standard "-Dsun.net.client.defaultConnectTimeout=<value>" property
* from https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html
*
* <p>
* To quickly see the debug log, execute the test with the property "-Dorg.slf4j.simpleLogger.log.org.jboss.windup=debug"
*/
@RunWith(Parameterized.class)
Expand Down Expand Up @@ -75,6 +75,8 @@ public class WindupRulesLinksTest {
CERT_FAILURE_LINKS.add("https://in.relation.to/2015/05/11/hibernate-search-530-beta-1-with-native-lucene-faceting/");
}

private static final int RETRIES = 5;

@Parameterized.Parameters(name = "{index}: Test {0}")
public static Iterable<File> data()
{
Expand Down Expand Up @@ -156,25 +158,31 @@ private boolean isValidLink(final String link)
if (CERT_FAILURE_LINKS.contains(link))
return true;

try {
final long starTime = System.currentTimeMillis();
if (!CACHE_ANALYZED_LINKS.containsKey(link))
{
final URL url = new URL(link);
final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
// property name from https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html
urlConn.setConnectTimeout(Integer.getInteger("sun.net.client.defaultConnectTimeout", 5000));
urlConn.connect();
CACHE_ANALYZED_LINKS.put(link, urlConn.getResponseCode());
final long starTime = System.currentTimeMillis();
int returnCode = 0;
if (!CACHE_ANALYZED_LINKS.containsKey(link)) {
for (int retry = 0; !ACCEPTED_RESPONSE_CODE.contains(returnCode) && retry < RETRIES; retry++) {
if (retry > 0) LOG.warn(String.format("Tentative #%d to connect to %s", retry + 1, link));
try {
final URL url = new URL(link);
final HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
// property name from https://docs.oracle.com/javase/8/docs/technotes/guides/net/properties.html
urlConn.setConnectTimeout(Integer.getInteger("sun.net.client.defaultConnectTimeout", 5000));
urlConn.addRequestProperty("User-Agent", "Mozilla/5.0 (X11; Linux x86_64; rv:121.0) Gecko/20100101 Firefox/121.0");
urlConn.connect();
returnCode = urlConn.getResponseCode();
} catch (IOException e) {
LOG.error(String.format("'%s' exception connecting to %s", e.getMessage(), link), e);
}
}
final boolean validLink = ACCEPTED_RESPONSE_CODE.contains(CACHE_ANALYZED_LINKS.get(link));
if (validLink) LOG.debug(String.format("Response code %d for %s [%dms]", CACHE_ANALYZED_LINKS.get(link), link, System.currentTimeMillis() - starTime));
else LOG.error(String.format("Response code %d for %s [%dms]", CACHE_ANALYZED_LINKS.get(link), link, System.currentTimeMillis() - starTime));
return validLink;
} catch (IOException e) {
LOG.error(String.format("'%s' exception connecting to %s", e.getMessage(), link), e);
return false;
CACHE_ANALYZED_LINKS.put(link, returnCode);
}
final boolean validLink = ACCEPTED_RESPONSE_CODE.contains(CACHE_ANALYZED_LINKS.get(link));
if (validLink)
LOG.debug(String.format("Response code %d for %s [%dms]", CACHE_ANALYZED_LINKS.get(link), link, System.currentTimeMillis() - starTime));
else
LOG.error(String.format("Response code %d for %s [%dms]", CACHE_ANALYZED_LINKS.get(link), link, System.currentTimeMillis() - starTime));
return validLink;
}

private String buildListOfFailedRulesLinks(final Map<String, List<String>> failedRulesWithLinks)
Expand Down

0 comments on commit 674c832

Please sign in to comment.