-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also avoid falling back always to getSource().getResource since it will produce a misleading error when actually using the prefix (which looks like a uri).
- Loading branch information
Showing
2 changed files
with
6 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
*/ | ||
package org.apache.catalina; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.net.URISyntaxException; | ||
|
@@ -1997,6 +1998,7 @@ default Resource findConfigFileResource(String name) throws IOException { | |
stream.close(); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
} | ||
throw new FileNotFoundException(name); | ||
This comment has been minimized.
Sorry, something went wrong.
michael-o
Member
|
||
} | ||
return ConfigFileLoader.getSource().getResource(name); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,9 +16,7 @@ | |
*/ | ||
package org.apache.catalina.core; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Map.Entry; | ||
import java.util.Objects; | ||
import java.util.Properties; | ||
|
@@ -30,6 +28,7 @@ | |
import org.apache.juli.logging.Log; | ||
import org.apache.juli.logging.LogFactory; | ||
import org.apache.tomcat.util.file.ConfigFileLoader; | ||
import org.apache.tomcat.util.file.ConfigurationSource.Resource; | ||
import org.apache.tomcat.util.res.StringManager; | ||
|
||
/** | ||
|
@@ -107,32 +106,10 @@ public void lifecycleEvent(LifecycleEvent event) { | |
log.warn(sm.getString("listener.notContext", event.getLifecycle().getClass().getSimpleName())); | ||
return; | ||
} | ||
Context context = (Context) event.getLifecycle(); | ||
|
||
InputStream is; | ||
if (roleMappingFile.startsWith(WEBAPP_PROTOCOL)) { | ||
String path = roleMappingFile.substring(WEBAPP_PROTOCOL.length()); | ||
is = context.getServletContext().getResourceAsStream(path); | ||
} else { | ||
try { | ||
is = ConfigFileLoader.getSource().getResource(roleMappingFile).getInputStream(); | ||
} catch (FileNotFoundException e1) { | ||
is = null; | ||
} catch (IOException e2) { | ||
throw new IllegalStateException( | ||
sm.getString("propertiesRoleMappingListener.roleMappingFileFail", roleMappingFile), e2); | ||
} | ||
} | ||
|
||
if (is == null) { | ||
throw new IllegalStateException( | ||
sm.getString("propertiesRoleMappingListener.roleMappingFileNotFound", roleMappingFile)); | ||
} | ||
|
||
Properties props = new Properties(); | ||
|
||
try (InputStream _is = is) { | ||
props.load(_is); | ||
Context context = (Context) event.getLifecycle(); | ||
try (Resource resource = context.findConfigFileResource(roleMappingFile)) { | ||
props.load(resource.getInputStream()); | ||
} catch (IOException e) { | ||
This comment has been minimized.
Sorry, something went wrong.
michael-o
Member
|
||
throw new IllegalStateException( | ||
sm.getString("propertiesRoleMappingListener.roleMappingFileFail", roleMappingFile), e); | ||
|
Now this be a fallthrough to FNFE which isn't right. It should be:
throw new IOException(sm.getString("catalinaConfigurationSource.cannotObtainURL", name), e);