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

Dependency updates #134

Merged
merged 6 commits into from
Oct 20, 2017
Merged

Dependency updates #134

merged 6 commits into from
Oct 20, 2017

Conversation

jglick
Copy link
Member

@jglick jglick commented Oct 20, 2017

Subsumes #133 and fixes the bug turned up there.

@reviewbybees esp. @oleg-nenashev

@ghost
Copy link

ghost commented Oct 20, 2017

This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation.

@jglick
Copy link
Member Author

jglick commented Oct 20, 2017

I think I figured out why the databinding bug has not been noticed before: as per JENKINS-27901, Jenkins form controls do not support binding collections of anything other than Describables. So the fact that Stapler supported binding String[] / List<String> but not Integer[] / List<Integer> was just irrelevant from the PoV of Jenkins, which never pretended to support any of these. So why did @kohsuke write a unit test for a feature which does not exist? Who knows…

BTW

diff --git a/core/src/test/java/org/kohsuke/stapler/DataBindingTest.java b/core/src/test/java/org/kohsuke/stapler/DataBindingTest.java
index 2d8c8e276..b267687ea 100644
--- a/core/src/test/java/org/kohsuke/stapler/DataBindingTest.java
+++ b/core/src/test/java/org/kohsuke/stapler/DataBindingTest.java
@@ -136,11 +136,12 @@ public class DataBindingTest extends TestCase {
     }
 
     public void testScalarToArray() throws Exception {
-        ScalarToArray r = bind("{a:'x',b:'y',c:5,d:6}", ScalarToArray.class);
+        ScalarToArray r = bind("{a:'x',b:'y',c:5,d:6,e:7}", ScalarToArray.class);
         assertEquals("x",r.a[0]);
         assertEquals("y",r.b.get(0));
         assertEquals(Integer.valueOf(5), r.c[0]);
         assertEquals(Integer.valueOf(6), r.d.get(0));
+        assertEquals(7, r.e[0]);
     }
 
     public static class ScalarToArray {
@@ -148,13 +149,15 @@ public class DataBindingTest extends TestCase {
         private List<String> b;
         private Integer[] c;
         private List<Integer> d;
+        private int[] e;
 
         @DataBoundConstructor
-        public ScalarToArray(String[] a, List<String> b, Integer[] c, List<Integer> d) {
+        public ScalarToArray(String[] a, List<String> b, Integer[] c, List<Integer> d, int[] e) {
             this.a = a;
             this.b = b;
             this.c = c;
             this.d = d;
+            this.e = e;
         }
     }
 

fails:

java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
	at org.jvnet.tiger_types.Lister$1.toCollection(Lister.java:109)
	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:746)
	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:478)
	at org.kohsuke.stapler.RequestImpl.instantiate(RequestImpl.java:777)
	at org.kohsuke.stapler.RequestImpl.access$200(RequestImpl.java:83)
	at org.kohsuke.stapler.RequestImpl$TypePair.convertJSON(RequestImpl.java:678)
	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:478)
	at org.kohsuke.stapler.RequestImpl.bindJSON(RequestImpl.java:474)
	at org.kohsuke.stapler.DataBindingTest.bind(DataBindingTest.java:170)
	at org.kohsuke.stapler.DataBindingTest.bind(DataBindingTest.java:165)
	at org.kohsuke.stapler.DataBindingTest.testScalarToArray(DataBindingTest.java:139)

For the reasons mentioned here, I am not going to bother trying to fix that.

@@ -742,7 +742,7 @@ public Object convertJSON(Object o) {
if (converter==null)
throw new IllegalArgumentException("Unable to convert to "+l.itemType);

l.add(converter.convert(type,o));
l.add(converter.convert(l.itemType, o));
Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

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

🐝 and @reviewbybees done

@jglick jglick merged commit 04889cf into jenkinsci:master Oct 20, 2017
@jglick jglick deleted the updates branch October 20, 2017 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants