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 {
return Config.fromJSON(new File(configPath));
} 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);
return Config.fromJSON(is);
} 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 {
return Config.fromJSON(new File(configPath));
} 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);
return Config.fromJSON(is);
} 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 {
return Config.fromJSON(new File(configPath));
} 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);
return Config.fromJSON(is);
} 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 {
return Config.fromJSON(new File(configPath));
} 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);
return Config.fromJSON(is);
} 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 {
return Config.fromJSON(new File(configPath));
} 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);
return Config.fromJSON(is);
} 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 {
config = Config.fromJSON(new File(configPath), getClass().getClassLoader());
} 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);
throw ex;
}

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

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

Loading…
Cancel
Save