Merge pull request #22385 from vpavic
* pr/22385: Polish "Ensure indexer gracefully handle missing meta annotations" Ensure indexer gracefully handle missing meta annotations
This commit is contained in:
commit
1152e67bb7
|
@ -4,5 +4,6 @@ dependencies {
|
|||
testCompile(project(":spring-context"))
|
||||
testCompile("javax.inject:javax.inject:1")
|
||||
testCompile("javax.annotation:javax.annotation-api:1.3.2")
|
||||
testCompile("javax.transaction:javax.transaction-api:1.3")
|
||||
testCompile("org.eclipse.persistence:javax.persistence:2.2.0")
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.context.index.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import javax.annotation.processing.ProcessingEnvironment;
|
||||
import javax.lang.model.element.AnnotationMirror;
|
||||
|
@ -110,7 +111,13 @@ class TypeHelper {
|
|||
}
|
||||
|
||||
public List<? extends AnnotationMirror> getAllAnnotationMirrors(Element e) {
|
||||
return this.env.getElementUtils().getAllAnnotationMirrors(e);
|
||||
try {
|
||||
return this.env.getElementUtils().getAllAnnotationMirrors(e);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
// This may fail if one of the annotation is not available
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import javax.persistence.Converter;
|
|||
import javax.persistence.Embeddable;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
|
@ -44,6 +45,7 @@ import org.springframework.context.index.sample.SampleRepository;
|
|||
import org.springframework.context.index.sample.SampleService;
|
||||
import org.springframework.context.index.sample.cdi.SampleManagedBean;
|
||||
import org.springframework.context.index.sample.cdi.SampleNamed;
|
||||
import org.springframework.context.index.sample.cdi.SampleTransactional;
|
||||
import org.springframework.context.index.sample.jpa.SampleConverter;
|
||||
import org.springframework.context.index.sample.jpa.SampleEmbeddable;
|
||||
import org.springframework.context.index.sample.SampleEmbedded;
|
||||
|
@ -67,6 +69,7 @@ import static org.springframework.context.index.processor.Metadata.*;
|
|||
* Tests for {@link CandidateComponentsIndexer}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author Vedran Pavic
|
||||
*/
|
||||
public class CandidateComponentsIndexerTests {
|
||||
|
||||
|
@ -142,6 +145,11 @@ public class CandidateComponentsIndexerTests {
|
|||
testSingleComponent(SampleNamed.class, Named.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cdiTransactional() {
|
||||
testSingleComponent(SampleTransactional.class, Transactional.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void persistenceEntity() {
|
||||
testSingleComponent(SampleEntity.class, Entity.class);
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.context.index.sample.cdi;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
/**
|
||||
* Test candidate for {@link Transactional}. This verifies that the annotation processor
|
||||
* can process an annotation that declares itself an annotation that is not on the
|
||||
* classpath.
|
||||
*
|
||||
* @author Vedran Pavic
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@Transactional
|
||||
public class SampleTransactional {
|
||||
}
|
Loading…
Reference in New Issue