This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git
The following commit(s) were added to refs/heads/master by this push:
new 6bb884c [KARAF-6120] Fix Windows separator confusing regex in Profiles
new e8e0260 Merge pull request #742 from diamondq/KARAF-6120
6bb884c is described below
commit 6bb884c2cddf4d9d6779e94e509c98bfd77dca52
Author: Mike Mansell <[email protected]>
AuthorDate: Tue Jan 29 14:15:43 2019 -0800
[KARAF-6120] Fix Windows separator confusing regex in Profiles
A number of places are using the String.replaceAll() method to
inject/remove the file system path separator. In the case of Windows, the \ is
a regex partial escape sequence. replaceAll()'s parameters are part of regex.
Instead, using replace() to fix the problem.
---
profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java
b/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java
index ebf5b0a..01fba3e 100644
--- a/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java
+++ b/profile/src/main/java/org/apache/karaf/profile/impl/Profiles.java
@@ -65,7 +65,7 @@ public final class Profiles {
if (profileId.endsWith("/")) {
profileId = profileId.substring(0,
profileId.length() - 1);
}
- profileId =
profileId.replaceAll(root.getFileSystem().getSeparator(), "-");
+ profileId =
profileId.replace(root.getFileSystem().getSeparator(), "-");
profileId = profileId.substring(0, profileId.length()
- PROFILE_FOLDER_SUFFIX.length());
builder = ProfileBuilder.Factory.create(profileId);
}
@@ -104,7 +104,7 @@ public final class Profiles {
* @throws IOException
*/
public static void deleteProfile(Path root, String id) throws IOException {
- Path path = root.resolve(id.replaceAll("-",
root.getFileSystem().getSeparator()) + PROFILE_FOLDER_SUFFIX);
+ Path path = root.resolve(id.replace("-",
root.getFileSystem().getSeparator()) + PROFILE_FOLDER_SUFFIX);
if (Files.isDirectory(path)) {
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
@Override
@@ -129,7 +129,7 @@ public final class Profiles {
* @throws IOException
*/
public static void writeProfile(Path root, Profile profile) throws
IOException {
- Path path = root.resolve(profile.getId().replaceAll("-",
root.getFileSystem().getSeparator()) + PROFILE_FOLDER_SUFFIX);
+ Path path = root.resolve(profile.getId().replace("-",
root.getFileSystem().getSeparator()) + PROFILE_FOLDER_SUFFIX);
Files.createDirectories(path);
for (Map.Entry<String, byte[]> entry :
profile.getFileConfigurations().entrySet()) {
Files.write(path.resolve(entry.getKey()), entry.getValue(),
StandardOpenOption.CREATE_NEW);