This is an automated email from the ASF dual-hosted git repository.
radu pushed a commit to branch master
in repository
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-starter-startup.git
The following commit(s) were added to refs/heads/master by this push:
new 54e998d SLING-7258 -
org.apache.sling.starter.startup.impl.StartupFilter should return 503 when
Sling is starting
54e998d is described below
commit 54e998d96517fd4248a00a6dd9281acbce1d691d
Author: Radu Cotescu <[email protected]>
AuthorDate: Wed Nov 22 12:31:43 2017 +0100
SLING-7258 - org.apache.sling.starter.startup.impl.StartupFilter should
return 503 when Sling is starting
* removed redundant null check for content
* added fallback if reading from embedded file fails
---
.../sling/starter/startup/impl/StartupFilter.java | 35 +++++++++++-----------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git
a/src/main/java/org/apache/sling/starter/startup/impl/StartupFilter.java
b/src/main/java/org/apache/sling/starter/startup/impl/StartupFilter.java
index 9a92990..ce3f6f3 100644
--- a/src/main/java/org/apache/sling/starter/startup/impl/StartupFilter.java
+++ b/src/main/java/org/apache/sling/starter/startup/impl/StartupFilter.java
@@ -21,7 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.util.stream.Collectors;
import javax.servlet.Filter;
@@ -41,26 +41,25 @@ public class StartupFilter implements Filter {
private String content;
StartupFilter() {
- if (content == null) {
- InputStream is =
StartupFilter.class.getClassLoader().getResourceAsStream("index.html");
- if (is != null) {
- BufferedReader buffer = null;
- try {
- buffer = new BufferedReader(new InputStreamReader(is,
"UTF-8"));
- content =
buffer.lines().collect(Collectors.joining(System.lineSeparator()));
- } catch (UnsupportedEncodingException e) {
- LOG.error("Cannot read embedded HTML page.", e);
- } finally {
- if (buffer != null) {
- try {
- buffer.close();
- } catch (IOException e) {
- LOG.error("Unable to release resource.", e);
- }
+ InputStream is =
StartupFilter.class.getClassLoader().getResourceAsStream("index.html");
+ if (is != null) {
+ BufferedReader buffer = null;
+ try {
+ buffer = new BufferedReader(new InputStreamReader(is,
StandardCharsets.UTF_8));
+ content =
buffer.lines().collect(Collectors.joining(System.lineSeparator()));
+ } finally {
+ if (buffer != null) {
+ try {
+ buffer.close();
+ } catch (IOException e) {
+ LOG.error("Unable to release resource.", e);
}
}
}
-
+ }
+ if (content == null || "".equals(content)) {
+ content = "<html><head><meta http-equiv=\"refresh\"
content=\"5\"><title>Apache Sling</title></head><body>" +
+ "<h1>Apache Sling is starting up....</h1></body></html>";
}
}
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].