Cherry picking 34ac90c on top of the 2.2.x branch

This commit is contained in:
Ryan Baxter
2020-03-09 10:46:44 -04:00
parent a228d4c5e8
commit db0319d2f1
3 changed files with 13 additions and 3 deletions

View File

@@ -145,14 +145,16 @@ public class ResourceController {
// ensure InputStream will be closed to prevent file locks on Windows
try (InputStream is = resource.getInputStream()) {
String text = StreamUtils.copyToString(is, Charset.forName("UTF-8"));
String ext = StringUtils.getFilenameExtension(resource.getFilename())
.toLowerCase();
String ext = StringUtils.getFilenameExtension(resource.getFilename());
if (ext != null) {
ext = ext.toLowerCase();
}
Environment environment = this.environmentRepository.findOne(name, profile,
label, false);
if (resolvePlaceholders) {
text = resolvePlaceholders(prepareEnvironment(environment), text);
}
if (encryptEnabled && plainTextEncryptEnabled) {
if (ext != null && encryptEnabled && plainTextEncryptEnabled) {
ResourceEncryptor re = this.resourceEncryptorMap.get(ext);
if (re == null) {
logger.warn("Cannot decrypt for extension " + ext);

View File

@@ -175,6 +175,13 @@ public class ResourceControllerTests {
assertThat(resource).isEqualToIgnoringNewLines("foo: dev_bar/spam");
}
@Test
public void resourceWithoutFileExtension() throws Exception {
this.environmentRepository.setSearchLocations("classpath:/test");
String resource = this.controller.retrieve("foo", "bar", "dev", "foo", true);
assertThat(resource).isEqualToIgnoringNewLines("foo: dev_bar");
}
@Test
public void resourceWithSlash() throws Exception {
this.environmentRepository.setSearchLocations("classpath:/test");

View File

@@ -0,0 +1 @@
foo: dev_bar