You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2023/01/30 12:05:50 UTC

[logging-log4j-tools] branch windows-fixes updated: Try prefixing Windows template paths with a slash

This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch windows-fixes
in repository https://gitbox.apache.org/repos/asf/logging-log4j-tools.git


The following commit(s) were added to refs/heads/windows-fixes by this push:
     new ce0e364  Try prefixing Windows template paths with a slash
ce0e364 is described below

commit ce0e3644365c3f4eaa314bf2c818cdb13ee7b913
Author: Volkan Yazıcı <vo...@yazi.ci>
AuthorDate: Mon Jan 30 13:07:09 2023 +0100

    Try prefixing Windows template paths with a slash
---
 .../org/apache/logging/log4j/changelog/exporter/FreeMarkerUtils.java  | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/exporter/FreeMarkerUtils.java b/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/exporter/FreeMarkerUtils.java
index aca4cc9..efc03e8 100644
--- a/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/exporter/FreeMarkerUtils.java
+++ b/log4j-changelog/src/main/java/org/apache/logging/log4j/changelog/exporter/FreeMarkerUtils.java
@@ -62,7 +62,9 @@ final class FreeMarkerUtils {
         // Since we are using `FileTemplateLoader`, template names refer to actual file paths.
         // On Windows, this causes failures; FreeMarker doesn't allow backslashes in the template name.
         // As a workaround, we are replacing backslashes with slashes.
-        final String templateName = templateFile.toAbsolutePath().toString().replace('\\', '/');
+        final String templateName = File.separatorChar == '/'
+                ? templateFile.toAbsolutePath().toString()
+                : ('/' + templateFile.toAbsolutePath().toString().replace('\\', '/'));
         try {
             final Template template = CONFIGURATION.getTemplate(templateName);
             final Path outputFileParent = outputFile.getParent();