diff --git a/redisson-hibernate/redisson-hibernate-4/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java b/redisson-hibernate/redisson-hibernate-4/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java index 5028691e6..83f4d453f 100644 --- a/redisson-hibernate/redisson-hibernate-4/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java +++ b/redisson-hibernate/redisson-hibernate-4/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java @@ -113,11 +113,11 @@ public class RedissonRegionFactory implements RegionFactory { private Config loadConfig(String configPath) { try { - return Config.fromJSON(new File(configPath)); + return Config.fromYAML(new File(configPath)); } catch (IOException e) { // trying next format try { - return Config.fromYAML(new File(configPath)); + return Config.fromJSON(new File(configPath)); } catch (IOException e1) { throw new CacheException("Can't parse default yaml config", e1); } @@ -128,11 +128,11 @@ public class RedissonRegionFactory implements RegionFactory { InputStream is = classLoader.getResourceAsStream(fileName); if (is != null) { try { - return Config.fromJSON(is); + return Config.fromYAML(is); } catch (IOException e) { try { is = classLoader.getResourceAsStream(fileName); - return Config.fromYAML(is); + return Config.fromJSON(is); } catch (IOException e1) { throw new CacheException("Can't parse yaml config", e1); } diff --git a/redisson-hibernate/redisson-hibernate-5/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java b/redisson-hibernate/redisson-hibernate-5/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java index 8532263b7..3131852cb 100644 --- a/redisson-hibernate/redisson-hibernate-5/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java +++ b/redisson-hibernate/redisson-hibernate-5/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java @@ -111,11 +111,11 @@ import java.util.Properties; private Config loadConfig(String configPath) { try { - return Config.fromJSON(new File(configPath)); + return Config.fromYAML(new File(configPath)); } catch (IOException e) { // trying next format try { - return Config.fromYAML(new File(configPath)); + return Config.fromJSON(new File(configPath)); } catch (IOException e1) { throw new CacheException("Can't parse default yaml config", e1); } @@ -126,11 +126,11 @@ import java.util.Properties; InputStream is = classLoader.getResourceAsStream(fileName); if (is != null) { try { - return Config.fromJSON(is); + return Config.fromYAML(is); } catch (IOException e) { try { is = classLoader.getResourceAsStream(fileName); - return Config.fromYAML(is); + return Config.fromJSON(is); } catch (IOException e1) { throw new CacheException("Can't parse yaml config", e1); } diff --git a/redisson-hibernate/redisson-hibernate-52/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java b/redisson-hibernate/redisson-hibernate-52/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java index 9e805657f..3add5b909 100644 --- a/redisson-hibernate/redisson-hibernate-52/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java +++ b/redisson-hibernate/redisson-hibernate-52/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java @@ -111,11 +111,11 @@ public class RedissonRegionFactory implements RegionFactory { private Config loadConfig(String configPath) { try { - return Config.fromJSON(new File(configPath)); + return Config.fromYAML(new File(configPath)); } catch (IOException e) { // trying next format try { - return Config.fromYAML(new File(configPath)); + return Config.fromJSON(new File(configPath)); } catch (IOException e1) { throw new CacheException("Can't parse default yaml config", e1); } @@ -126,11 +126,11 @@ public class RedissonRegionFactory implements RegionFactory { InputStream is = classLoader.getResourceAsStream(fileName); if (is != null) { try { - return Config.fromJSON(is); + return Config.fromYAML(is); } catch (IOException e) { try { is = classLoader.getResourceAsStream(fileName); - return Config.fromYAML(is); + return Config.fromJSON(is); } catch (IOException e1) { throw new CacheException("Can't parse yaml config", e1); } diff --git a/redisson-hibernate/redisson-hibernate-53/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java b/redisson-hibernate/redisson-hibernate-53/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java index 1e1114dc1..3f12fa60a 100644 --- a/redisson-hibernate/redisson-hibernate-53/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java +++ b/redisson-hibernate/redisson-hibernate-53/src/main/java/org/redisson/hibernate/RedissonRegionFactory.java @@ -120,11 +120,11 @@ public class RedissonRegionFactory extends RegionFactoryTemplate { private Config loadConfig(String configPath) { try { - return Config.fromJSON(new File(configPath)); + return Config.fromYAML(new File(configPath)); } catch (IOException e) { // trying next format try { - return Config.fromYAML(new File(configPath)); + return Config.fromJSON(new File(configPath)); } catch (IOException e1) { throw new CacheException("Can't parse default yaml config", e1); } @@ -135,11 +135,11 @@ public class RedissonRegionFactory extends RegionFactoryTemplate { InputStream is = classLoader.getResourceAsStream(fileName); if (is != null) { try { - return Config.fromJSON(is); + return Config.fromYAML(is); } catch (IOException e) { try { is = classLoader.getResourceAsStream(fileName); - return Config.fromYAML(is); + return Config.fromJSON(is); } catch (IOException e1) { throw new CacheException("Can't parse yaml config", e1); } diff --git a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index c9eca52c9..b8929b052 100644 --- a/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-7/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -331,11 +331,11 @@ public class RedissonSessionManager extends ManagerBase { protected RedissonClient buildClient() throws LifecycleException { Config config = null; try { - config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); diff --git a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index b285e2fc4..6bfac701c 100644 --- a/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-8/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -331,11 +331,11 @@ public class RedissonSessionManager extends ManagerBase { protected RedissonClient buildClient() throws LifecycleException { Config config = null; try { - config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); diff --git a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java index b285e2fc4..6bfac701c 100644 --- a/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java +++ b/redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java @@ -331,11 +331,11 @@ public class RedissonSessionManager extends ManagerBase { protected RedissonClient buildClient() throws LifecycleException { Config config = null; try { - config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { log.error("Can't parse json config " + configPath, e); throw new LifecycleException("Can't parse yaml config " + configPath, e1); diff --git a/redisson/src/main/java/org/redisson/JndiRedissonFactory.java b/redisson/src/main/java/org/redisson/JndiRedissonFactory.java index e5c3bd322..10f904838 100644 --- a/redisson/src/main/java/org/redisson/JndiRedissonFactory.java +++ b/redisson/src/main/java/org/redisson/JndiRedissonFactory.java @@ -48,11 +48,11 @@ public class JndiRedissonFactory implements ObjectFactory { protected RedissonClient buildClient(String configPath) throws NamingException { Config config = null; try { - config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); + config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { - config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); + config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { NamingException ex = new NamingException("Can't parse yaml config " + configPath); ex.initCause(e1); diff --git a/redisson/src/main/java/org/redisson/jcache/JCachingProvider.java b/redisson/src/main/java/org/redisson/jcache/JCachingProvider.java index bbfacf80f..e45246c6c 100644 --- a/redisson/src/main/java/org/redisson/jcache/JCachingProvider.java +++ b/redisson/src/main/java/org/redisson/jcache/JCachingProvider.java @@ -98,27 +98,27 @@ public class JCachingProvider implements CachingProvider { private Config loadConfig(URI uri) { Config config = null; try { - URL jsonUrl = null; + URL yamlUrl = null; if (DEFAULT_URI_PATH.equals(uri.getPath())) { - jsonUrl = JCachingProvider.class.getResource("/redisson-jcache.json"); + yamlUrl = JCachingProvider.class.getResource("/redisson-jcache.yaml"); } else { - jsonUrl = uri.toURL(); + yamlUrl = uri.toURL(); } - if (jsonUrl == null) { - throw new IOException(); + if (yamlUrl != null) { + config = Config.fromYAML(yamlUrl); } - config = Config.fromJSON(jsonUrl); } catch (IOException e) { try { - URL yamlUrl = null; + URL jsonUrl = null; if (DEFAULT_URI_PATH.equals(uri.getPath())) { - yamlUrl = JCachingProvider.class.getResource("/redisson-jcache.yaml"); + jsonUrl = JCachingProvider.class.getResource("/redisson-jcache.json"); } else { - yamlUrl = uri.toURL(); + jsonUrl = uri.toURL(); } - if (yamlUrl != null) { - config = Config.fromYAML(yamlUrl); + if (jsonUrl == null) { + throw new IOException(); } + config = Config.fromJSON(jsonUrl); } catch (IOException e2) { // skip }