Skip to content

Commit

Permalink
[FIXED JENKINS-18178] Reverting an inessential part of the fix of JEN…
Browse files Browse the repository at this point in the history
…KINS-16301 since it broke some Maven builds.

Apparently the Maven 2 process factory fails to adequately insulate the Maven process from Jenkins library dependencies;
if you specify a build extension that can override dependencies used by Jenkins core classes!
A real fix would involve changing class loader delegation, since presumably similar bugs could still occur.
  • Loading branch information
jglick committed Jul 24, 2013
1 parent 74d57de commit e0a3a1d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
3 changes: 3 additions & 0 deletions changelog.html
Expand Up @@ -67,6 +67,9 @@
<li class='major bug'>
Since 1.520, Jenkins requires Java 6 or later, breaking Maven builds set to use JDK 5. Now falls back to JVM of slave agent but sets compile/test flags to use defined JDK.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18403">issue 18403</a>)
<li class='major bug'>
Since 1.517, Maven projects using Maven 2 could not build projects using extensions depending on Apache Commons Codec.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-18178">issue 18178</a>)
<li class=bug>
Provided maven settings.xml in maven builder is lost.
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-15976">issue 15976</a>)
Expand Down
19 changes: 19 additions & 0 deletions core/src/main/java/hudson/Util.java
Expand Up @@ -30,6 +30,7 @@
import hudson.Proc.LocalProc;
import hudson.model.TaskListener;
import hudson.os.PosixAPI;
import hudson.util.IOException2;
import hudson.util.QuotedStringTokenizer;
import hudson.util.VariableResolver;
import hudson.util.jna.WinIOException;
Expand Down Expand Up @@ -72,6 +73,7 @@
import hudson.util.jna.Kernel32Utils;

import static hudson.util.jna.GNUCLibrary.LIBC;
import java.security.DigestInputStream;
import org.apache.commons.codec.digest.DigestUtils;

/**
Expand Down Expand Up @@ -554,11 +556,28 @@ public static String ensureEndsWith(String subject, String suffix) {
* @see DigestUtils#md5Hex(InputStream)
*/
public static String getDigestOf(InputStream source) throws IOException {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");

byte[] buffer = new byte[1024];
DigestInputStream in =new DigestInputStream(source,md5);
try {
while(in.read(buffer)>=0)
; // simply discard the input
} finally {
in.close();
}
return toHexString(md5.digest());
} catch (NoSuchAlgorithmException e) {
throw new IOException2("MD5 not installed",e); // impossible
}
/* JENKINS-18178: confuses Maven 2 runner
try {
return DigestUtils.md5Hex(source);
} finally {
source.close();
}
*/
}

public static String getDigestOf(String text) {
Expand Down
18 changes: 15 additions & 3 deletions test/src/test/java/hudson/maven/MavenBuildTest.java
Expand Up @@ -8,17 +8,16 @@
import hudson.tasks.Maven.MavenInstallation;
import hudson.tasks.test.AbstractTestResultAction;
import hudson.tasks.test.AggregatedTestResultAction;
import hudson.tasks.test.TestResultProjectAction;

import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;

import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.Email;
import org.jvnet.hudson.test.ExtractResourceSCM;
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.SingleFileSCM;

/**
* @author Kohsuke Kawaguchi
Expand Down Expand Up @@ -177,7 +176,20 @@ public void testMavenFailsafePluginTestResultsAreRecorded() throws Exception {
AbstractTestResultAction<?> testResultAction = moduleBuild.getTestResultAction();
assertNotNull(testResultAction);
assertEquals(1, testResultAction.getTotalCount());
}
}

@Bug(18178)
public void testExtensionsConflictingWithCore() throws Exception {
MavenModuleSet m = createMavenProject();
m.setMaven(configureDefaultMaven().getName());
m.setScm(new SingleFileSCM("pom.xml",
"<project><modelVersion>4.0.0</modelVersion>" +
"<groupId>g</groupId><artifactId>a</artifactId><version>0</version>" +
"<build><extensions>" +
"<extension><groupId>org.springframework.build.aws</groupId><artifactId>org.springframework.build.aws.maven</artifactId><version>3.0.0.RELEASE</version></extension>" +
"</extensions></build></project>"));
buildAndAssertSuccess(m);
}

private static class TestReporter extends MavenReporter {
private static final long serialVersionUID = 1L;
Expand Down

0 comments on commit e0a3a1d

Please sign in to comment.