ClassPathResource uses specific constructors in createRelative

Issue: SPR-16146

(cherry picked from commit d00e4f1)
This commit is contained in:
Juergen Hoeller
2017-11-02 16:05:57 +01:00
parent 9470719cdb
commit 573ff2c58d
2 changed files with 67 additions and 54 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -197,7 +197,8 @@ public class ClassPathResource extends AbstractFileResolvingResource {
@Override
public Resource createRelative(String relativePath) {
String pathToUse = StringUtils.applyRelativePath(this.path, relativePath);
return new ClassPathResource(pathToUse, this.classLoader, this.clazz);
return (this.clazz != null ? new ClassPathResource(pathToUse, this.clazz) :
new ClassPathResource(pathToUse, this.classLoader));
}
/**