Skip to content

Commit

Permalink
Merge pull request #63 from batmat/java11-readiness
Browse files Browse the repository at this point in the history
Make the plugin Java 11 ready -- Remove JAXB usage
  • Loading branch information
stephenc authored Mar 21, 2019
2 parents 406ca6f + 59801ae commit bbf9667
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
buildPlugin()
buildPlugin(configurations: buildPlugin.recommendedConfigurations())
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>3.24</version>
<version>3.40</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -65,10 +65,10 @@
</scm>

<properties>
<revision>2.3.3</revision>
<revision>2.4.0</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.7.3</jenkins.version>
<java.level>7</java.level>
<jenkins.version>2.60.3</jenkins.version>
<java.level>8</java.level>
<no-test-jar>false</no-test-jar>
</properties>

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/jenkins/scm/impl/form/NamedArrayList.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -38,6 +40,8 @@
*
* @param <E> the type of element.
*/
@SuppressFBWarnings(value = "EQ_DOESNT_OVERRIDE_EQUALS",
justification = "On purpose ignoring 'name' field, not changing current behavior present since ~2 years")
public class NamedArrayList<E> extends ArrayList<E> {
/**
* The associated name.
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/jenkins/scm/impl/mock/MockSCMController.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.regex.Pattern;
import jenkins.scm.api.SCMFile;
import jenkins.scm.api.SCMNavigatorOwner;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.jvnet.hudson.test.recipes.LocalData;
Expand Down Expand Up @@ -601,7 +602,7 @@ public String getHash() {
sha.update(e.getKey().getBytes(StandardCharsets.UTF_8));
sha.update(e.getValue());
}
hash = javax.xml.bind.DatatypeConverter.printHexBinary(sha.digest()).toLowerCase();
this.hash = toHexBinary(sha.digest());
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("SHA-1 message digest mandated by JLS");
}
Expand All @@ -610,6 +611,10 @@ public String getHash() {
}
}

static String toHexBinary(byte[] bytes) {
return new String(Hex.encodeHex(bytes));
}

public static final class LogEntry {
private final String hash;
private final long timestamp;
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/jenkins/scm/impl/mock/MockSCMControllerTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package jenkins.scm.impl.mock;

import org.junit.Test;

import java.security.MessageDigest;

import static org.junit.Assert.assertEquals;

public class MockSCMControllerTest {

@Test
public void toHexBinary() throws Exception {
final MessageDigest msg = MessageDigest.getInstance("SHA-1");
msg.update("blah".getBytes());
assertEquals("5bf1fd927dfb8679496a2e6cf00cbe50c1c87145", MockSCMController.toHexBinary(msg.digest()));
}
}

0 comments on commit bbf9667

Please sign in to comment.