Skip to content

Commit

Permalink
[FIX JENKINS-46122] Report base class name when symbol couldn't be re…
Browse files Browse the repository at this point in the history
…solved
  • Loading branch information
Vlatombe committed Aug 10, 2017
1 parent 0194fee commit 25aa7a8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Expand Up @@ -445,7 +445,7 @@ private Object coerce(String context, Type type, Object o) throws Exception {
}
}
}
throw new UnsupportedOperationException("Undefined symbol ‘" + symbol + "’");
throw new UnsupportedOperationException("no known implementation of " + base + " is using symbol ‘" + symbol + "’");
}

if (Modifier.isAbstract(base.getModifiers())) {
Expand Down
27 changes: 27 additions & 0 deletions plugin/src/test/java/org/jenkinsci/plugins/structs/FishingRod.java
@@ -0,0 +1,27 @@
package org.jenkinsci.plugins.structs;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* "rod" symbol
*
* @author Kohsuke Kawaguchi
*/
public class FishingRod extends AbstractDescribableImpl<FishingRod> implements Fishing {
@DataBoundConstructor
public FishingRod() {
}


@Extension @Symbol("rod")
public static class DescriptorImpl extends Descriptor<FishingRod> {
@Override
public String getDisplayName() {
return "fishing rod";
}
}
}
Expand Up @@ -676,6 +676,17 @@ public void resolveClass() throws Exception {
assertEquals(Internet.class, DescribableModel.resolveClass(Tech.class, "Internet", null));
}

@Issue("JENKINS-46122")
@Test
public void resolveSymbolOnWrongBaseClass() throws Exception {
try {
DescribableModel.resolveClass(Tech.class, null, "rod");
fail("No symbol for Tech should exist.");
} catch (UnsupportedOperationException e) {
assertEquals("no known implementation of " + Tech.class + " is using symbol ‘rod’", e.getMessage());
}
}

@Test
public void singleRequiredParameter() throws Exception {
// positive case
Expand Down

0 comments on commit 25aa7a8

Please sign in to comment.