From f7aed2a333cf866fe983836ff7d8ae6279c9b8a1 Mon Sep 17 00:00:00 2001 From: Seol_JY Date: Wed, 14 Aug 2024 14:06:40 +0900 Subject: [PATCH] Polishing. Replace Collection.class.isInstance with instanceof for type checking. Remove unnecessary type check for ConfigurableListableBeanFactory in postProcessBeanFactory method. Closes #3580 --- .../repository/config/JpaRepositoryConfigExtension.java | 2 +- ...EntityManagerBeanDefinitionRegistrarPostProcessor.java | 8 +------- .../data/jpa/repository/support/SimpleJpaRepository.java | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigExtension.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigExtension.java index 7188c0c184..7010542f45 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigExtension.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/config/JpaRepositoryConfigExtension.java @@ -195,7 +195,7 @@ public void registerBeansForRoot(BeanDefinitionRegistry registry, RepositoryConf registerIfNotAlreadyRegistered(() -> { - Object value = AnnotationRepositoryConfigurationSource.class.isInstance(config) // + Object value = config instanceof AnnotationRepositoryConfigurationSource // ? config.getRequiredAttribute(ESCAPE_CHARACTER_PROPERTY, Character.class) // : config.getAttribute(ESCAPE_CHARACTER_PROPERTY).orElse("\\"); diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessor.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessor.java index d48c84af96..a3344c2c94 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessor.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/EntityManagerBeanDefinitionRegistrarPostProcessor.java @@ -55,13 +55,7 @@ public int getOrder() { @Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { - if (!ConfigurableListableBeanFactory.class.isInstance(beanFactory)) { - return; - } - - ConfigurableListableBeanFactory factory = beanFactory; - - for (EntityManagerFactoryBeanDefinition definition : getEntityManagerFactoryBeanDefinitions(factory)) { + for (EntityManagerFactoryBeanDefinition definition : getEntityManagerFactoryBeanDefinitions(beanFactory)) { BeanFactory definitionFactory = definition.getBeanFactory(); diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java index 067cc8a56f..7ee27c1304 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/support/SimpleJpaRepository.java @@ -247,7 +247,7 @@ public void deleteAllByIdInBatch(Iterable ids) { * Some JPA providers require {@code ids} to be a {@link Collection} so we must convert if it's not already. */ - if (Collection.class.isInstance(ids)) { + if (ids instanceof Collection) { query.setParameter("ids", ids); } else { Collection idsCollection = StreamSupport.stream(ids.spliterator(), false)