You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vk...@apache.org on 2018/08/17 00:25:35 UTC
ignite git commit: IGNITE-9031: SpringCacheManager throws
AssertionError during Spring initialization - Fixed #4511
Repository: ignite
Updated Branches:
refs/heads/master 2df990ccd -> eebbf8b9d
IGNITE-9031: SpringCacheManager throws AssertionError during Spring initialization - Fixed #4511
Signed-off-by: Valentin Kulichenko <va...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/eebbf8b9
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/eebbf8b9
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/eebbf8b9
Branch: refs/heads/master
Commit: eebbf8b9da5a811081f386a5de4fa1a9491669f3
Parents: 2df990c
Author: Amir Akhmedov <am...@gmail.com>
Authored: Thu Aug 16 17:24:16 2018 -0700
Committer: Valentin Kulichenko <va...@gmail.com>
Committed: Thu Aug 16 17:24:16 2018 -0700
----------------------------------------------------------------------
.../ignite/cache/spring/SpringCacheManager.java | 35 ++++++++++----------
.../spring/SpringTransactionManager.java | 30 ++++++++---------
...ridSpringCacheManagerSpringBeanSelfTest.java | 14 +++++---
...ingTransactionManagerSpringBeanSelfTest.java | 6 ++++
4 files changed, 49 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/eebbf8b9/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java b/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
index 0b02f4c..7fb9383 100644
--- a/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
+++ b/modules/spring/src/main/java/org/apache/ignite/cache/spring/SpringCacheManager.java
@@ -315,26 +315,27 @@ public class SpringCacheManager implements CacheManager, ApplicationListener<Con
/** {@inheritDoc} */
@Override public void onApplicationEvent(ContextRefreshedEvent event) {
- assert ignite == null;
+ if (ignite == null) {
- if (cfgPath != null && cfg != null) {
- throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " +
- "provided. Set only one of these properties if you need to start a Ignite node inside of " +
- "SpringCacheManager. If you already have a node running, omit both of them and set" +
- "'igniteInstanceName' property.");
- }
+ if (cfgPath != null && cfg != null) {
+ throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " +
+ "provided. Set only one of these properties if you need to start a Ignite node inside of " +
+ "SpringCacheManager. If you already have a node running, omit both of them and set" +
+ "'igniteInstanceName' property.");
+ }
- try {
- if (cfgPath != null) {
- ignite = IgniteSpring.start(cfgPath, springCtx);
+ try {
+ if (cfgPath != null) {
+ ignite = IgniteSpring.start(cfgPath, springCtx);
+ }
+ else if (cfg != null)
+ ignite = IgniteSpring.start(cfg, springCtx);
+ else
+ ignite = Ignition.ignite(igniteInstanceName);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
}
- else if (cfg != null)
- ignite = IgniteSpring.start(cfg, springCtx);
- else
- ignite = Ignition.ignite(igniteInstanceName);
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/eebbf8b9/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java b/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
index 57c099a..bc9dd16 100644
--- a/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
+++ b/modules/spring/src/main/java/org/apache/ignite/transactions/spring/SpringTransactionManager.java
@@ -344,26 +344,26 @@ public class SpringTransactionManager extends AbstractPlatformTransactionManager
/** {@inheritDoc} */
@Override public void onApplicationEvent(ContextRefreshedEvent event) {
- assert ignite == null;
-
- if (cfgPath != null && cfg != null) {
- throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " +
+ if (ignite == null) {
+ if (cfgPath != null && cfg != null) {
+ throw new IllegalArgumentException("Both 'configurationPath' and 'configuration' are " +
"provided. Set only one of these properties if you need to start a Ignite node inside of " +
"SpringCacheManager. If you already have a node running, omit both of them and set" +
"'igniteInstanceName' property.");
- }
+ }
- try {
- if (cfgPath != null) {
- ignite = IgniteSpring.start(cfgPath, springCtx);
+ try {
+ if (cfgPath != null) {
+ ignite = IgniteSpring.start(cfgPath, springCtx);
+ }
+ else if (cfg != null)
+ ignite = IgniteSpring.start(cfg, springCtx);
+ else
+ ignite = Ignition.ignite(igniteInstanceName);
+ }
+ catch (IgniteCheckedException e) {
+ throw U.convertException(e);
}
- else if (cfg != null)
- ignite = IgniteSpring.start(cfg, springCtx);
- else
- ignite = Ignition.ignite(igniteInstanceName);
- }
- catch (IgniteCheckedException e) {
- throw U.convertException(e);
}
if (transactionConcurrency == null)
http://git-wip-us.apache.org/repos/asf/ignite/blob/eebbf8b9/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSpringBeanSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSpringBeanSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSpringBeanSelfTest.java
index 8557cc2..8c5fc10 100644
--- a/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSpringBeanSelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/cache/spring/GridSpringCacheManagerSpringBeanSelfTest.java
@@ -17,8 +17,9 @@
package org.apache.ignite.cache.spring;
-import org.springframework.beans.factory.BeanFactory;
+import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.context.support.GenericXmlApplicationContext;
/**
* Spring cache test.
@@ -27,10 +28,15 @@ public class GridSpringCacheManagerSpringBeanSelfTest extends GridSpringCacheMan
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
- BeanFactory factory = new ClassPathXmlApplicationContext("org/apache/ignite/cache/spring/spring-caching-ignite-spring-bean.xml");
+ ApplicationContext appCtx = new ClassPathXmlApplicationContext("org/apache/ignite/cache/spring/spring-caching-ignite-spring-bean.xml");
- svc = (GridSpringCacheTestService)factory.getBean("testService");
- dynamicSvc = (GridSpringDynamicCacheTestService)factory.getBean("dynamicTestService");
+ // To produce multiple calls of ApplicationListener::onApplicationEvent
+ GenericXmlApplicationContext child = new GenericXmlApplicationContext();
+ child.setParent(appCtx);
+ child.refresh();
+
+ svc = (GridSpringCacheTestService)appCtx.getBean("testService");
+ dynamicSvc = (GridSpringDynamicCacheTestService)appCtx.getBean("dynamicTestService");
}
/** {@inheritDoc} */
http://git-wip-us.apache.org/repos/asf/ignite/blob/eebbf8b9/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSpringBeanSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSpringBeanSelfTest.java b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSpringBeanSelfTest.java
index f98952f..6ed14cf 100644
--- a/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSpringBeanSelfTest.java
+++ b/modules/spring/src/test/java/org/apache/ignite/transactions/spring/GridSpringTransactionManagerSpringBeanSelfTest.java
@@ -41,6 +41,12 @@ public class GridSpringTransactionManagerSpringBeanSelfTest extends GridSpringTr
/** {@inheritDoc} */
@Override protected void beforeTest() throws Exception {
ApplicationContext appCtx = new GenericXmlApplicationContext("config/spring-transactions-ignite-spring-bean.xml");
+
+ // To produce multiple calls of ApplicationListener::onApplicationEvent
+ GenericXmlApplicationContext child = new GenericXmlApplicationContext();
+ child.setParent(appCtx);
+ child.refresh();
+
ignite = (Ignite)appCtx.getBean("mySpringBean");
service = (GridSpringTransactionService)appCtx.getBean("gridSpringTransactionService");
}