Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.1</version>
<version>4.17</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -67,7 +67,7 @@
<properties>
<revision>2.6.5</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.176.4</jenkins.version>
<jenkins.version>2.222.4</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
<hpi.compatibleSinceVersion>2.0.0</hpi.compatibleSinceVersion>
Expand All @@ -90,8 +90,8 @@
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.176.x</artifactId>
<version>9</version>
<artifactId>bom-2.222.x</artifactId>
<version>26</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
32 changes: 29 additions & 3 deletions src/main/java/jenkins/scm/api/SCMName.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@
import com.google.common.net.InternetDomainName;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.IDN;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

import org.apache.commons.lang.StringUtils;

/**
Expand Down Expand Up @@ -142,10 +146,32 @@ private static String resolveInternetDomainName(String hostName) {
}

if (host.hasPublicSuffix()) {
final String publicName = host.publicSuffix().name();
return StringUtils.removeEnd(StringUtils.removeEnd(host.name(), publicName), ".").toLowerCase(Locale.ENGLISH);
final String publicName = name(host.publicSuffix());
return StringUtils.removeEnd(StringUtils.removeEnd(name(host), publicName), ".").toLowerCase(Locale.ENGLISH);
}

return StringUtils.removeEnd(host.name(), ".").toLowerCase(Locale.ENGLISH);
return StringUtils.removeEnd(name(host), ".").toLowerCase(Locale.ENGLISH);
}

/**
* The full domain name, converted to lower case.
* It calls {@code InternetDomainName#name()} or falls back to {@link InternetDomainName#toString()}
* for compatibility with newer (&gt; 22.0) versions of guava.
*
* @since TODO
*/
private static String name(InternetDomainName host) {
try {
try {
// Guava older than ~22
Method method = InternetDomainName.class.getMethod("name");
return (String) method.invoke(host);
} catch (NoSuchMethodException e) {
// TODO invert this to prefer the newer guava method once guava is upgrade in Jenkins core
return host.toString();
}
} catch (IllegalAccessException | InvocationTargetException e ) {
throw new RuntimeException(e);
}
}
}
63 changes: 0 additions & 63 deletions src/test/java/jenkins/scm/api/MessagesTest.java

This file was deleted.

63 changes: 0 additions & 63 deletions src/test/java/jenkins/scm/impl/MessagesTest.java

This file was deleted.