Skip to content

Commit 970eff2

Browse files
Merge pull request #2205 from sajinieKavindya/new-master
Check for existence of path separator before removing the last character from registry entryKey
2 parents 530ca4d + f6144f7 commit 970eff2

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

modules/core/src/main/java/org/apache/synapse/unittest/UnitTestMockRegistry.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,20 @@ private String getAbsolutePathToRegistry(String key) {
177177
public Properties getResourceProperties(String entryKey) {
178178
Properties propertySet = new Properties();
179179

180-
String filePathAsKey = entryKey.substring(0, entryKey.length() - 1) + ".properties";
181-
String resourcePath = getAbsolutePathToRegistry(filePathAsKey);
180+
String formattedEntryKey = entryKey;
181+
if (entryKey.endsWith(Constants.BACK_SLASH)) {
182+
formattedEntryKey = entryKey.substring(0, entryKey.length() - 1);
183+
}
184+
185+
String resourcePath = getAbsolutePathToRegistry(formattedEntryKey + ".properties");
182186
boolean isFoundPropertyFile = false;
183187

184188
//check registry has .properties file for the properties with key
185189
if (resourcePath != null && testMockRegistry.containsKey(resourcePath)) {
186190
isFoundPropertyFile = true;
187191
} else {
188192
//check registry has file for the properties with key
189-
filePathAsKey = entryKey.substring(0, entryKey.length() - 1);
190-
resourcePath = getAbsolutePathToRegistry(filePathAsKey);
193+
resourcePath = getAbsolutePathToRegistry(formattedEntryKey);
191194

192195
if (resourcePath != null && testMockRegistry.containsKey(resourcePath)) {
193196
isFoundPropertyFile = true;

0 commit comments

Comments
 (0)