Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt the test for recent core #857

Merged
merged 4 commits into from
Mar 29, 2020
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import hudson.security.csrf.CrumbFilter;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;

Expand Down Expand Up @@ -32,6 +34,16 @@ public class GitStatusCrumbExclusionTest {
private HttpServletResponse resp;
private FilterChain chain;

@BeforeClass
public static void setProps() {
System.setProperty("hudson.security.csrf.CrumbFilter.UNPROCESSED_PATHINFO", "true");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it safer to get the old value and restore it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the code. Feel free to commit directly to the PR.

Copy link
Contributor

@MarkEWaite MarkEWaite Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I checked out this pull request and modified pom.xml to allow it to compile with Jenkins 2.204.6, I get a null pointer exception in the unsetProps call.

java.lang.NullPointerException
        at java.util.Hashtable.put(Hashtable.java:460)
        at java.util.Properties.setProperty(Properties.java:166)
        at java.lang.System.setProperty(System.java:798)
        at hudson.plugins.git.GitStatusCrumbExclusionTest.unsetProps(GitStatusCrumbExclusionTest.java:47)

If I discard the most recent commit, then the test passes with a new spotbugs warning about a possible null pointer dereference in GitRevisionBuildParameters. That warning is a nice reminder that newer Jenkins versions include annotations which can help spotbugs find more problems for us.

I think this PR and jenkins-infra/jenkins.io#3002 highlight that it is time for the git plugin and the git client plugin to require a Jenkins version that is newer than 2.138.4.

I think that we should consider incrementing the major version of the git plugin and the git client plugin and have them depend on Jenkins 2.190.3. I think that would allow us to avoid several dependency related issues that are caused by the overly broad range of Jenkins versions supported by the git plugin and the git client plugin.

@fcojfernandez and @rsandell do you have concerns if we make git plugin require Jenkins 2.190.3 instead of 2.138.4? I'll also start a discussion in the git-plugin gitter channel

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarkEWaite Good catch ;) corrected

}

@AfterClass
public static void unsetProps() {
System.setProperty("hudson.security.csrf.CrumbFilter.UNPROCESSED_PATHINFO", "");
}

@Before
public void before() {
filter = new CrumbFilter();
Expand Down