Skip to content

Commit

Permalink
Use Xstream2#addCriticalField directly instead of via reflection
Browse files Browse the repository at this point in the history
Since Jenkins 2.85 (https://jenkins.io/changelog/#v2.85) this method is available for plugins.
  • Loading branch information
darxriggs committed Sep 4, 2019
1 parent 90bf5be commit e03881d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</licenses>

<properties>
<jenkins.version>2.60.3</jenkins.version>
<jenkins.version>2.85</jenkins.version>
<java.level>8</java.level>
<workflow.version>1.0</workflow.version> <!-- only for testing purpose -->
</properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
import hudson.model.Queue;
import hudson.util.FormApply;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
Expand All @@ -49,8 +47,6 @@
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import javax.servlet.ServletException;

import hudson.util.XStream2;
import jenkins.model.Jenkins;
import jenkins.model.TransientActionFactory;
import net.sf.json.JSONObject;
Expand Down Expand Up @@ -138,10 +134,8 @@ public Authentication authenticate(Queue.Item item) {
* This method is responsible for ensuring that POSTing config.xml respects the defined strategy.
*/
@Initializer(after = InitMilestone.PLUGINS_STARTED)
public static void setStrategyCritical() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
//TODO the reflection could be removed when the addCriticalField will be un-restricted (PR: https://github.com/jenkinsci/jenkins/pull/3066)
Method method = XStream2.class.getMethod("addCriticalField", Class.class, String.class);
method.invoke(Items.XSTREAM2, AuthorizeProjectProperty.class, "strategy");
public static void setStrategyCritical() {
Items.XSTREAM2.addCriticalField(AuthorizeProjectProperty.class, "strategy");
}

/**
Expand Down

0 comments on commit e03881d

Please sign in to comment.