Fixed - error during Yaml configuration parsing isn't reported. #4985

pull/5004/head
Nikita Koksharov 2 years ago
parent 2065270e9d
commit 8b76103d26

@ -116,7 +116,8 @@ public class RedissonRegionFactory implements RegionFactory {
try { try {
return Config.fromJSON(new File(configPath)); return Config.fromJSON(new File(configPath));
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse default yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse default config", e1);
} }
} }
} }
@ -131,7 +132,8 @@ public class RedissonRegionFactory implements RegionFactory {
is = classLoader.getResourceAsStream(fileName); is = classLoader.getResourceAsStream(fileName);
return Config.fromJSON(is); return Config.fromJSON(is);
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse config", e1);
} }
} }
} }

@ -123,7 +123,8 @@ import java.util.concurrent.atomic.AtomicLong;
try { try {
return Config.fromJSON(new File(configPath)); return Config.fromJSON(new File(configPath));
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse default yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse default config", e1);
} }
} }
} }
@ -138,7 +139,8 @@ import java.util.concurrent.atomic.AtomicLong;
is = classLoader.getResourceAsStream(fileName); is = classLoader.getResourceAsStream(fileName);
return Config.fromJSON(is); return Config.fromJSON(is);
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse config", e1);
} }
} }
} }

@ -124,7 +124,8 @@ public class RedissonRegionFactory implements RegionFactory {
try { try {
return Config.fromJSON(new File(configPath)); return Config.fromJSON(new File(configPath));
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse default yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse default config", e1);
} }
} }
} }
@ -139,7 +140,8 @@ public class RedissonRegionFactory implements RegionFactory {
is = classLoader.getResourceAsStream(fileName); is = classLoader.getResourceAsStream(fileName);
return Config.fromJSON(is); return Config.fromJSON(is);
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse config", e1);
} }
} }
} }

@ -124,7 +124,8 @@ public class RedissonRegionFactory extends RegionFactoryTemplate {
try { try {
return Config.fromJSON(new File(configPath)); return Config.fromJSON(new File(configPath));
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse default yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse default config", e1);
} }
} }
} }
@ -139,7 +140,8 @@ public class RedissonRegionFactory extends RegionFactoryTemplate {
is = classLoader.getResourceAsStream(fileName); is = classLoader.getResourceAsStream(fileName);
return Config.fromJSON(is); return Config.fromJSON(is);
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse config", e1);
} }
} }
} }

@ -125,7 +125,8 @@ public class RedissonRegionFactory extends RegionFactoryTemplate {
try { try {
return Config.fromJSON(new File(configPath)); return Config.fromJSON(new File(configPath));
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse default yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse default config", e1);
} }
} }
} }
@ -140,7 +141,8 @@ public class RedissonRegionFactory extends RegionFactoryTemplate {
is = classLoader.getResourceAsStream(fileName); is = classLoader.getResourceAsStream(fileName);
return Config.fromJSON(is); return Config.fromJSON(is);
} catch (IOException e1) { } catch (IOException e1) {
throw new CacheException("Can't parse yaml config", e1); e1.addSuppressed(e);
throw new CacheException("Can't parse config", e1);
} }
} }
} }

@ -54,7 +54,8 @@ public class JndiRedissonFactory implements ObjectFactory {
try { try {
config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
} catch (IOException e1) { } catch (IOException e1) {
NamingException ex = new NamingException("Can't parse yaml config " + configPath); NamingException ex = new NamingException("Can't parse config " + configPath);
e1.addSuppressed(e);
ex.initCause(e1); ex.initCause(e1);
throw ex; throw ex;
} }

@ -88,14 +88,14 @@ public final class RedissonNode {
String configPath = args[0]; String configPath = args[0];
RedissonNodeFileConfig config = null; RedissonNodeFileConfig config = null;
try { try {
config = RedissonNodeFileConfig.fromJSON(new File(configPath)); config = RedissonNodeFileConfig.fromYAML(new File(configPath));
} catch (IOException e) { } catch (IOException e) {
// trying next format // trying next format
try { try {
config = RedissonNodeFileConfig.fromYAML(new File(configPath)); config = RedissonNodeFileConfig.fromJSON(new File(configPath));
} catch (IOException e1) { } catch (IOException e1) {
log.error("Can't parse json config {}", configPath, e); e1.addSuppressed(e);
throw new IllegalArgumentException("Can't parse yaml config " + configPath, e1); throw new IllegalArgumentException("Can't parse config " + configPath, e1);
} }
} }

@ -298,12 +298,13 @@ public class RedissonSpringCacheManager implements CacheManager, ResourceLoaderA
Resource resource = resourceLoader.getResource(configLocation); Resource resource = resourceLoader.getResource(configLocation);
try { try {
this.configMap = (Map<String, CacheConfig>) CacheConfig.fromJSON(resource.getInputStream()); this.configMap = (Map<String, CacheConfig>) CacheConfig.fromYAML(resource.getInputStream());
} catch (IOException e) { } catch (IOException e) {
// try to read yaml // try to read yaml
try { try {
this.configMap = (Map<String, CacheConfig>) CacheConfig.fromYAML(resource.getInputStream()); this.configMap = (Map<String, CacheConfig>) CacheConfig.fromJSON(resource.getInputStream());
} catch (IOException e1) { } catch (IOException e1) {
e1.addSuppressed(e);
throw new BeanDefinitionStoreException( throw new BeanDefinitionStoreException(
"Could not parse cache configuration at [" + configLocation + "]", e1); "Could not parse cache configuration at [" + configLocation + "]", e1);
} }

Loading…
Cancel
Save