Skip to content
Permalink
Browse files
[FIXED JENKINS-37820] Stack overflow for classes which were their own…
… descriptors, common for global configuration.
  • Loading branch information
jglick committed Aug 30, 2016
1 parent c681aef commit 284e11be852078ec128dbe345f3dd40f5599c3ca
Showing with 21 additions and 16 deletions.
  1. +1 −2 plugin/src/main/java/org/jenkinsci/plugins/structs/SymbolLookup.java
  2. +18 −12 plugin/src/test/java/org/jenkinsci/plugins/structs/SymbolLookupTest.java
  3. +2 −2 pom.xml
@@ -14,7 +14,6 @@
import javax.inject.Inject;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@@ -185,7 +184,7 @@ public static SymbolLookup get() {
justification = "Jenkins.getInstance() can return null in theory.")
@Nonnull public static Set<String> getSymbolValue(@Nonnull Class<?> c) {
Set<String> symbolValues = new LinkedHashSet<String>();
if (Describable.class.isAssignableFrom(c) && Jenkins.getInstance() != null) {
if (Describable.class.isAssignableFrom(c) && !Descriptor.class.isAssignableFrom(c) && Jenkins.getInstance() != null) {
Descriptor d = Jenkins.getInstance().getDescriptor(c.asSubclass(Describable.class));
symbolValues.addAll(getSymbolValue(d));
} else {
@@ -1,25 +1,20 @@
package org.jenkinsci.plugins.structs;

import hudson.model.Descriptor;
import java.util.Collections;
import java.util.Set;
import javax.inject.Inject;
import jenkins.model.GlobalConfiguration;
import static org.hamcrest.CoreMatchers.*;
import org.jenkinsci.Symbol;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.TestExtension;

import javax.inject.Inject;

import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

/**
* @author Kohsuke Kawaguchi
*/
public class SymbolLookupTest {
@TestExtension @Symbol("foo")
public static class Foo {}
@@ -90,4 +85,15 @@ public void symbolValueFromClass() {
assertEquals(netSet, SymbolLookup.getSymbolValue(FishingNet.DescriptorImpl.class));
assertEquals(fooSet, SymbolLookup.getSymbolValue(Foo.class));
}

@Issue("JENKINS-37820")
@Test
public void descriptorIsDescribable() {
assertEquals(Collections.singleton("whatever"), SymbolLookup.getSymbolValue(SomeConfiguration.class));
assertEquals(Collections.singleton("whatever"), SymbolLookup.getSymbolValue(rule.jenkins.getDescriptorByType(SomeConfiguration.class)));
}
@TestExtension("descriptorIsDescribable")
@Symbol("whatever")
public static class SomeConfiguration extends GlobalConfiguration {}

}
@@ -4,8 +4,8 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.12</version>
<relativePath />
<version>2.14</version>
<relativePath/>
</parent>

<groupId>org.jenkins-ci.plugins</groupId>

0 comments on commit 284e11b

Please sign in to comment.