mirror of
https://github.com/Stirling-Tools/Stirling-PDF.git
synced 2025-05-25 03:12:02 +00:00
Fix TemplateResolver and LibreOfficeListener bugs (#3555)
## Summary - log missing exceptions in FileFallbackTemplateResolver - implement exists check for InputStreamTemplateResource - use LISTENER_PORT constant when verifying LibreOffice listener ## Testing - `./gradlew build --no-daemon` - `./gradlew test --no-daemon` --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
218d21f07a
commit
c8e25f4c5a
@ -31,7 +31,8 @@ public class LibreOfficeListener {
|
||||
log.info("waiting for listener to start");
|
||||
try (Socket socket = new Socket()) {
|
||||
socket.connect(
|
||||
new InetSocketAddress("localhost", 2002), 1000); // Timeout after 1 second
|
||||
new InetSocketAddress("localhost", LISTENER_PORT),
|
||||
1000); // Timeout after 1 second
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
@ -11,8 +11,11 @@ import org.thymeleaf.templateresolver.AbstractConfigurableTemplateResolver;
|
||||
import org.thymeleaf.templateresource.FileTemplateResource;
|
||||
import org.thymeleaf.templateresource.ITemplateResource;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import stirling.software.SPDF.model.InputStreamTemplateResource;
|
||||
|
||||
@Slf4j
|
||||
public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateResolver {
|
||||
|
||||
private final ResourceLoader resourceLoader;
|
||||
@ -40,7 +43,8 @@ public class FileFallbackTemplateResolver extends AbstractConfigurableTemplateRe
|
||||
return new FileTemplateResource(resource.getFile().getPath(), characterEncoding);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
// Log the exception to help with debugging issues loading external templates
|
||||
log.warn("Unable to read template '{}' from file system", resourceName, e);
|
||||
}
|
||||
|
||||
InputStream inputStream =
|
||||
|
@ -39,7 +39,6 @@ public class InputStreamTemplateResource implements ITemplateResource {
|
||||
|
||||
@Override
|
||||
public boolean exists() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
return inputStream != null;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user