You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ta...@apache.org on 2021/08/03 11:53:49 UTC

[skywalking] branch fix_webapp_refresh created (now 9e4c8c3)

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

tanjian pushed a change to branch fix_webapp_refresh
in repository https://gitbox.apache.org/repos/asf/skywalking.git.


      at 9e4c8c3  fix not found error when refresh ui.

This branch includes the following new commits:

     new 9e4c8c3  fix not found error when refresh ui.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[skywalking] 01/01: fix not found error when refresh ui.

Posted by ta...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tanjian pushed a commit to branch fix_webapp_refresh
in repository https://gitbox.apache.org/repos/asf/skywalking.git

commit 9e4c8c3caad59e292e0595dd92f27ad3d0b5eacc
Author: JaredTan95 <ji...@daocloud.io>
AuthorDate: Tue Aug 3 19:53:24 2021 +0800

    fix not found error when refresh ui.
---
 .../apm/webapp/GlobalErrorWebExceptionHandler.java | 54 ++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/GlobalErrorWebExceptionHandler.java b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/GlobalErrorWebExceptionHandler.java
new file mode 100644
index 0000000..34e6349
--- /dev/null
+++ b/apm-webapp/src/main/java/org/apache/skywalking/apm/webapp/GlobalErrorWebExceptionHandler.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.apm.webapp;
+
+import java.io.IOException;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.annotation.Order;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.buffer.DataBufferFactory;
+import org.springframework.http.MediaType;
+import org.springframework.http.server.reactive.ServerHttpResponse;
+import org.springframework.util.StreamUtils;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+@Slf4j
+@Order(-1)
+@Configuration
+public class GlobalErrorWebExceptionHandler implements ErrorWebExceptionHandler {
+
+    @Override
+    public Mono<Void> handle(ServerWebExchange exchange, Throwable ex) {
+        ServerHttpResponse response = exchange.getResponse();
+        response.getHeaders().setContentType(MediaType.TEXT_HTML);
+        return response.writeWith(Mono.fromSupplier(() -> {
+            DataBufferFactory bufferFactory = response.bufferFactory();
+            try {
+                return bufferFactory.wrap(StreamUtils.copyToByteArray(
+                    new ClassPathResource("/public/index.html").getInputStream()));
+            } catch (IOException e) {
+                log.error("There was an error completing the action.", ex);
+                return bufferFactory.wrap(new byte[0]);
+            }
+        }));
+    }
+}
\ No newline at end of file