|
1 | 1 | /* |
2 | | - * Copyright 2012-2016 the original author or authors. |
| 2 | + * Copyright 2012-2017 the original author or authors. |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -208,12 +208,7 @@ private void onApplicationPreparedEvent(ApplicationEvent event) { |
208 | 208 | protected void addPropertySources(ConfigurableEnvironment environment, |
209 | 209 | ResourceLoader resourceLoader) { |
210 | 210 | RandomValuePropertySource.addToEnvironment(environment); |
211 | | - try { |
212 | | - new Loader(environment, resourceLoader).load(); |
213 | | - } |
214 | | - catch (IOException ex) { |
215 | | - throw new IllegalStateException("Unable to load configuration files", ex); |
216 | | - } |
| 211 | + new Loader(environment, resourceLoader).load(); |
217 | 212 | } |
218 | 213 |
|
219 | 214 | /** |
@@ -339,7 +334,7 @@ private class Loader { |
339 | 334 | : resourceLoader; |
340 | 335 | } |
341 | 336 |
|
342 | | - public void load() throws IOException { |
| 337 | + public void load() { |
343 | 338 | this.propertiesLoader = new PropertySourcesLoader(); |
344 | 339 | this.activatedProfiles = false; |
345 | 340 | this.profiles = Collections.asLifoQueue(new LinkedList<Profile>()); |
@@ -423,8 +418,7 @@ private List<Profile> getUnprocessedActiveProfiles( |
423 | 418 | return unprocessedActiveProfiles; |
424 | 419 | } |
425 | 420 |
|
426 | | - private void load(String location, String name, Profile profile) |
427 | | - throws IOException { |
| 421 | + private void load(String location, String name, Profile profile) { |
428 | 422 | String group = "profile=" + (profile == null ? "" : profile); |
429 | 423 | if (!StringUtils.hasText(name)) { |
430 | 424 | // Try to load directly from the location |
@@ -456,6 +450,18 @@ private void load(String location, String name, Profile profile) |
456 | 450 | } |
457 | 451 |
|
458 | 452 | private PropertySource<?> loadIntoGroup(String identifier, String location, |
| 453 | + Profile profile) { |
| 454 | + try { |
| 455 | + return doLoadIntoGroup(identifier, location, profile); |
| 456 | + } |
| 457 | + catch (Exception ex) { |
| 458 | + throw new IllegalStateException( |
| 459 | + "Failed to load property source from location '" + location + "'", |
| 460 | + ex); |
| 461 | + } |
| 462 | + } |
| 463 | + |
| 464 | + private PropertySource<?> doLoadIntoGroup(String identifier, String location, |
459 | 465 | Profile profile) throws IOException { |
460 | 466 | Resource resource = this.resourceLoader.getResource(location); |
461 | 467 | PropertySource<?> propertySource = null; |
|
0 commit comments