@@ -57,6 +57,8 @@ public final class LoadingConfigurationBuilder
57
57
* EnumSets to collect them, so we have to do that...
58
58
*/
59
59
private static final EnumSet <JsonParser .Feature > DEFAULT_PARSER_FEATURES ;
60
+
61
+ private static final int DEFAULT_CACHE_SIZE = 512 ;
60
62
61
63
static {
62
64
DEFAULT_PARSER_FEATURES = EnumSet .noneOf (JsonParser .Feature .class );
@@ -78,14 +80,9 @@ public final class LoadingConfigurationBuilder
78
80
URITranslatorConfiguration translatorCfg ;
79
81
80
82
/**
81
- * Loaded schemas are cached by default
82
- */
83
- boolean enableCache = true ;
84
-
85
- /**
86
- * Cache size is 4096 by default
83
+ * Cache size is 512 by default
87
84
*/
88
- int cacheSize = 4096 ;
85
+ int cacheSize = DEFAULT_CACHE_SIZE ;
89
86
90
87
/**
91
88
* Dereferencing mode
@@ -137,28 +134,31 @@ public final class LoadingConfigurationBuilder
137
134
dereferencing = cfg .dereferencing ;
138
135
preloadedSchemas = Maps .newHashMap (cfg .preloadedSchemas );
139
136
parserFeatures = EnumSet .copyOf (cfg .parserFeatures );
140
- enableCache = cfg .enableCache ;
141
137
cacheSize = cfg .cacheSize ;
142
138
}
143
-
139
+
144
140
/**
145
141
* Should we enable caching of downloaded schemas
142
+ *
143
+ * @deprecated Just for backward compatibility
144
+ * Use cacheSize setter instead to set the maximum size of the cache
146
145
*
147
146
* <p>Note that this does <b>not</b> affect preloaded schemas</p>
148
147
*
149
148
* @param enableCache if loaded schemas have to be cached
150
149
* @return this
151
150
*/
151
+ @ Deprecated
152
152
public LoadingConfigurationBuilder setEnableCache (final boolean enableCache )
153
153
{
154
- this .enableCache = enableCache ;
154
+ this .cacheSize = enableCache ? DEFAULT_CACHE_SIZE : 0 ;
155
155
return this ;
156
156
}
157
157
158
158
/**
159
159
* How many schemas should be cached
160
- * <p>Note if enableCache is false this setting is ignored </p>
161
- * <p>Note setting enableCache to false or this to zero both effectively disable the cache</p>
160
+ * <p>Note setting to zero effectively disables the cache </p>
161
+ * <p>Note settting to -1 creates an unlimited cache</p>
162
162
* <p>Note that this does <b>not</b> affect preloaded schemas</p>
163
163
*
164
164
* @param cacheSize if loaded schemas have to be cached
0 commit comments