Commit 4f995ba
Refactor XMLFileResourceProvider to support read-only configuration directories
Enhance `XMLFileResourceProvider` to allow GeoWebCache to start with a
read-only configuration directory and `geowebcache.xml` file. Previously, the provider
assumed that the configuration directory was always writable, which caused startup
failures when running in environments with restricted file permissions.
- **Support read-only configuration directories**:
- `hasInput()` now correctly returns `true` if the configuration file
exists or if a template is available and the directory is writable.
- `hasOutput()` ensures that the configuration file can be written before
allowing output operations.
- Improved error handling when checking directory and file writability.
- **Refactored file existence checks**:
- Consolidated logic for checking configuration file existence and writability
into `findConfigFile()`.
- Moved the directory writability check from `findConfigFile()` to
`findOrCreateConfFile()` to prevent premature failures.
- **Improved logging and exception handling**:
- `hasInput()` and `hasOutput()` now log warnings when encountering errors
instead of failing silently.
- `findOrCreateConfFile()` now explicitly throws an exception when it cannot
create a new configuration file due to permission issues.
- GeoWebCache can now start successfully with a pre-existing, read-only configuration directory.
- Configurations stored in a read-only filesystem (e.g., mounted from a
read-only volume) can still be used without requiring write access.
- The provider only attempts to create a configuration file when explicitly
required, eliminating side effects from query methods `hasInput()` and
`hasOutput()`.
This change improves the resilience of GeoWebCache in constrained environments
while maintaining backward compatibility for writable configurations.1 parent 69b9d82 commit 4f995ba
File tree
3 files changed
+90
-16
lines changed- geowebcache/core/src
- main/java/org/geowebcache/config
- test/java/org/geowebcache/config
3 files changed
+90
-16
lines changedLines changed: 5 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
788 | 788 | | |
789 | 789 | | |
790 | 790 | | |
791 | | - | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
792 | 795 | | |
793 | 796 | | |
794 | 797 | | |
795 | 798 | | |
796 | | - | |
797 | | - | |
798 | | - | |
| 799 | + | |
799 | 800 | | |
800 | 801 | | |
801 | 802 | | |
| |||
Lines changed: 50 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
135 | 138 | | |
136 | 139 | | |
137 | 140 | | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
138 | 149 | | |
139 | 150 | | |
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
| |||
165 | 184 | | |
166 | 185 | | |
167 | 186 | | |
168 | | - | |
169 | | - | |
170 | | - | |
171 | 187 | | |
172 | 188 | | |
173 | 189 | | |
174 | 190 | | |
175 | 191 | | |
176 | 192 | | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
183 | | - | |
| 193 | + | |
184 | 194 | | |
185 | 195 | | |
186 | 196 | | |
| |||
200 | 210 | | |
201 | 211 | | |
202 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
203 | 218 | | |
204 | 219 | | |
205 | 220 | | |
| |||
249 | 264 | | |
250 | 265 | | |
251 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
252 | 274 | | |
253 | 275 | | |
254 | 276 | | |
255 | | - | |
| 277 | + | |
| 278 | + | |
256 | 279 | | |
| 280 | + | |
257 | 281 | | |
258 | 282 | | |
259 | 283 | | |
260 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
261 | 293 | | |
262 | 294 | | |
263 | | - | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
264 | 302 | | |
265 | 303 | | |
Lines changed: 35 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
| 53 | + | |
50 | 54 | | |
51 | 55 | | |
52 | 56 | | |
| |||
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
| 71 | + | |
67 | 72 | | |
68 | 73 | | |
69 | 74 | | |
| |||
557 | 562 | | |
558 | 563 | | |
559 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
560 | 595 | | |
0 commit comments