基於SpringBoot的接口開發以及報警信息入庫

背景:監控線上客戶端傳參日誌,詳見 https://blog.csdn.net/weixin_42498050/article/details/94219831

計劃:提供接口,報警信息入庫

報警信息入庫-未完待續

odps數據遷移至idb

odps的DDL語句:

CREATE TABLE `table_A` ( `content` STRING, `rowkey` STRING ) COMMENT 'TT source table' PARTITIONED BY ( ds STRING COMMENT 'day', hh STRING COMMENT 'hour', mm STRING COMMENT 'minutes' ) LIFECYCLE 600;

 

 

idb的DDL語句:

CREATE TABLE `table_B` (

`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '主鍵',

`gmt_create` datetime NOT NULL COMMENT '創建時間',

`gmt_modified` datetime NOT NULL COMMENT '修改時間',

`content` text NOT NULL COMMENT '客戶端傳參原始日誌',

`rowkey` varchar(100) NOT NULL COMMENT '標識',

`ds` varchar(50) NOT NULL COMMENT 'day',

`hh` varchar(50) NOT NULL COMMENT 'hour',

`mm` varchar(50) NOT NULL DEFAULT '' COMMENT 'minutes',

PRIMARY KEY (`id`)

) DEFAULT CHARACTER SET=utf8mb4 COMMENT='客戶端傳參監控';

 

因爲我自己的項目使用的日誌配置是log4j 而遷移之後的項目是slf4j。發現代碼裏log是飄紅的
 

 

首先解釋一下爲什麼要安裝Lombok插件–爲什麼呢?

因爲在idea導入項目的時候,你會看見,臥槽,都是錯誤,打開一個一個錯誤,就沒有不報錯誤的,log飄紅,提示Cannot resolve symbol‘log’,這就是因爲Lombok了原因了!

eclipse和idea開發環境下都有自動生成的bean,entity等類快捷方式,絕大部分數據類類中都需要get、set、toString、equals和hashCode方法,如果bean中的屬性一旦有修改、刪除或增加時,需要重新生成或刪除get/set等方法,給代碼維護增加負擔。

而使用了lombok則不一樣,使用了lombok的註解(@Setter, @Getter, @ToString, @RequiredArgsConstructor, @EqualsAndHashCode 或 @Data)之後,就不需要編寫或生成get/set等方法。

在線安裝bomlok插件

在intellig idea中選擇preferences -- plugs -- Search in repositories搜索lombok

install後Restart IntelliJ IDEA 重啓idea後,代碼正常

 

 

 

關於mybatis-generator-maven-plugin:2.0.0報錯解決:

百度了半天,找3個同事對比本地個人目錄下/Users/lishan/.m2/repository/com/taobao/tddl

最終發現同事的/Users/lishan/.m2/repository/com/taobao/tddl/tddl-common 下的版本爲 5.2.6-1    3.3.2.4      5.2.6 

而我自己的都是5以上的版本,缺少3.3.2.4版本

經排查爲/Users/lishan/.m2/settings.xml 與其他同事的配置不太一樣,導致每次運行mybatis-generator:generate時報錯如下。同事把tddl整個文化夾以及settings.xml發給我後,替換完成,重新加載maven配置,再運行generate就ok了

Downloading: http://jcenter.bintray.com/com/alibaba/configserver/google/code/gson/ali-gson/maven-metadata.xml
Downloading: https://jitpack.io/com/alibaba/configserver/google/code/gson/ali-gson/maven-metadata.xml
[INFO] 
[INFO] --- mybatis-generator-maven-plugin:2.0.0:generate (default-cli) @ algo-testing-service ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.886 s
[INFO] Finished at: 2019-11-05T19:49:31+08:00
[INFO] Final Memory: 28M/323M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.tmall.mybatis.generator:mybatis-generator-maven-plugin:2.0.0:generate (default-cli) on project algo-testing-service: Execution default-cli of goal com.tmall.mybatis.generator:mybatis-generator-maven-plugin:2.0.0:generate failed: A required class was missing while executing com.tmall.mybatis.generator:mybatis-generator-maven-plugin:2.0.0:generate: com/taobao/tddl/common/util/DataSourceFetcher
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>com.tmall.mybatis.generator:mybatis-generator-maven-plugin:2.0.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/lishan/.m2/repository/com/tmall/mybatis/generator/mybatis-generator-maven-plugin/2.0.0/mybatis-generator-maven-plugin-2.0.0.jar
[ERROR] urls[1] = file:/Users/lishan/.m2/repository/com/taobao/tddl/tddl-group-datasource/3.3.2.4/tddl-group-datasource-3.3.2.4.jar
[ERROR] urls[2] = file:/Users/lishan/.m2/repository/org/mybatis/generator/mybatis-generator-core/1.3.2/mybatis-generator-core-1.3.2.jar
[ERROR] urls[3] = file:/Users/lishan/.m2/repository/org/mybatis/generator/mybatis-generator-maven-plugin/1.3.0/mybatis-generator-maven-plugin-1.3.0.jar
[ERROR] urls[4] = file:/Users/lishan/.m2/repository/com/google/code/javaparser/javaparser/1.0.11/javaparser-1.0.11.jar
[ERROR] urls[5] = file:/Users/lishan/.m2/repository/javax/enterprise/cdi-api/1.0/cdi-api-1.0.jar
[ERROR] urls[6] = file:/Users/lishan/.m2/repository/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar
[ERROR] urls[7] = file:/Users/lishan/.m2/repository/org/eclipse/sisu/org.eclipse.sisu.inject/0.3.0/org.eclipse.sisu.inject-0.3.0.jar
[ERROR] urls[8] = file:/Users/lishan/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[9] = file:/Users/lishan/.m2/repository/backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar
[ERROR] urls[10] = file:/Users/lishan/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation-1.11.jar
[ERROR] urls[11] = file:/Users/lishan/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15.jar
[ERROR] urls[12] = file:/Users/lishan/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar
[ERROR] urls[13] = file:/Users/lishan/.m2/repository/org/apache/maven/reporting/maven-reporting-api/2.0.9/maven-reporting-api-2.0.9.jar
[ERROR] urls[14] = file:/Users/lishan/.m2/repository/org/apache/maven/doxia/doxia-sink-api/1.0-alpha-10/doxia-sink-api-1.0-alpha-10.jar
[ERROR] urls[15] = file:/Users/lishan/.m2/repository/commons-cli/commons-cli/1.0/commons-cli-1.0.jar
[ERROR] urls[16] = file:/Users/lishan/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-4/plexus-interactivity-api-1.0-alpha-4.jar
[ERROR] urls[17] = file:/Users/lishan/.m2/repository/commons-io/commons-io/2.1/commons-io-2.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------: com.taobao.tddl.common.util.DataSourceFetcher
[ERROR] -> [Help 1]

解決後運行生成

 

刪除之前的dependency

mvn clean -U test-compile
刷新就ok了,效果如下

 

 

關於Error creating bean with name 'cpwLogInfoController'

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cpwLogInfoController': Unsatisfied dependency expressed through field 'cpwLogInfoService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cpwLogInfoService': Unsatisfied dependency expressed through field 'cpwLogInfoDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.alibaba.algo.dao.CpwLogInfoDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

原因:可能的原因1

#import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.stereotype.Service;

導包錯誤導致,應爲 import org.springframework.stereotype.Service;

實際導包爲 #import com.alibaba.dubbo.config.annotation.Service;

是否確實與注入相關便籤的依賴。比如dubbo服務下,添加了spring的相關依賴但是服務端並不需要Spring的@Service標籤,而是dubbo的@Service標籤。檢查maven依賴是否正確,修改完畢記得Install,report下


參考博客   https://blog.csdn.net/butterfly_resting/article/details/80044863

但是並未解決:真正的原因如下 是dao下的CpwLogInfoDao需要添加@Mapper @Repository

import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

@Mapper
@Repository

修改之後運行,ok

 

基於SpringBoot springframework框架的項目設計

=================================================================================

=================================================================================

1> 設計好自己的數據表。我這裏是3張

從odps同步到idb的數據

CREATE TABLE `cpw_log_info` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主鍵',
  `gmt_create` datetime NOT NULL COMMENT '創建時間',
  `gmt_modified` datetime NOT NULL COMMENT '修改時間',
  `content` text NOT NULL COMMENT '客戶端傳參原始日誌',
  `rowkey` varchar(100) NOT NULL COMMENT '標識',
  `ds` varchar(50) NOT NULL COMMENT 'day',
  `hh` varchar(50) NOT NULL COMMENT 'hour',
  `mm` varchar(50) NOT NULL DEFAULT '' COMMENT 'minutes',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COMMENT='客戶端傳參監控'
;
 

存儲傳參日誌的原始日誌,odps讀取的前N條數據

CREATE TABLE `cpw_log_save` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主鍵',
  `gmt_create` datetime NOT NULL COMMENT '創建時間',
  `gmt_modified` datetime NOT NULL COMMENT '修改時間',
  `log_id` int(11) NOT NULL COMMENT 'content讀取odps的第N條數據',
  `origial_param` text COMMENT 'odps的第N條日誌原始參數',
  `now_time` varchar(50) DEFAULT NULL COMMENT '讀取opdps時間,當前時間,年月日',
  `log_time` varchar(50) DEFAULT NULL COMMENT '日誌的時間戳',
  `utdid` varchar(50) DEFAULT NULL COMMENT '用戶utdid信息',
  `app_scene` varchar(50) DEFAULT NULL COMMENT '搜索場景',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=512 DEFAULT CHARSET=utf8mb4 COMMENT='客戶端傳參日誌實時監控'
;
 

存儲newcpw解析斷言後的錯誤日誌

CREATE TABLE `cpw_log_error` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主鍵',
  `gmt_create` datetime NOT NULL COMMENT '創建時間',
  `gmt_modified` datetime NOT NULL COMMENT '修改時間',
  `now_time` varchar(50) NOT NULL COMMENT 'log運行時間',
  `log_id` int(11) NOT NULL COMMENT '讀取odps的日誌id',
  `error_log` text COMMENT '錯誤參數信息',
  `error_level` int(11) DEFAULT NULL COMMENT '錯誤級別',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='客戶端傳參錯誤日誌入庫'
;
 

2> 分爲testing-service和testing-start,在service.resources下面的Generator.xml添加配置文件

<table tableName="cpw_log_info">
    <generatedKey column="id" sqlStatement="SELECT LAST_INSERT_ID() as id" type="post"
                  identity="true"></generatedKey>
</table>

<table tableName="cpw_log_save">
    <generatedKey column="id" sqlStatement="SELECT LAST_INSERT_ID() as id" type="post"
                  identity="true"></generatedKey>
</table>

<table tableName="cpw_log_error">
    <generatedKey column="id" sqlStatement="SELECT LAST_INSERT_ID() as id" type="post"
                  identity="true"></generatedKey>
</table>

3> 生成beans文件

3.1> 點擊idea右側Maven-testing-serivice-Plugins-mybatis-generator

3.2> 在service- dao包下自動生成Dao接口和Query類===對數據庫函數的封裝,接口

 

注意:需要在所有Dao接口文件下添加如下註解(方法的標籤,註解)

@Mapper

@Repository

 

3.3> 在service- mode包自動下生成Do文件===對數據庫字段屬性的封裝,get set方法。即JavaBeans

 

3.4> 在service- resources- mapper自動生成xml文件

mapper是對數據庫增刪改查方法的封裝

3.5> /XX-testing/algo-testing-service/src/main/java/com/xx/newcpw/CpwLogErrorServer.java

是執行對數據庫操作的入口,Service層

 

3.6> /XX-testing/algo-testing-start/src/main/java/com/xx/algo/controller/CpwLogErrorController.java

是業務數據對數據庫的處理(增刪改查)Dao Do ,controller層

 

3.7> 啓動Spring Boot:修改testing-start/Application.java運行程序入口,修改完成以debug模式啓運行 

package com.alibaba.algo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import com.taobao.pandora.boot.PandoraBootstrap;

/**
 * Pandora Boot應用的入口類
 * <p>LogUtil
 * 詳情見http://xx/middleware-container/pandora-boot/wikis/spring-boot-diamond
 *
 * @author
 */
@SpringBootApplication(scanBasePackages = {"com.alibaba.algo","com.xx.xx","com.xx.xx","com.xx.newcpw"})
public class Application {

    public static void main(String[] args) {
        PandoraBootstrap.run(args);
        SpringApplication.run(Application.class, args);
        PandoraBootstrap.markStartupAndWait();
    }
}

 

3.8> 請求寫好的接口,http://localhost:port/logsave   把原始日誌寫入數據表cpw_log_save

    http://localhost:port/logerror   把錯誤日誌寫入數據表cpw_log_error

 

 

關於SpringBoot遇到的問題

如遇Failure to find com.aliyun:aliyun-java-sdk-core:pom:3.4.0 in http://mvnrepo.alibaba-inc.com/mvn/repository was cached in the local repository, resolution will not be reattempted until the update interval of tbmirror-all has elapsed or updates are forced

解決如下兩個問題
解決settings.xml修改鏡像地址不生效的問題,
解決maven打包構建時出現如下問題

Failure to find com.ibatis:xxx-xxx-plugin:jar:1.0.7 in http://maven.aliyun.com/nexus/content/repositories/central/ was cached in the local repository,
resolution will not be reattempted until the update interval of alimaven has elapsed or updates are forced ->

問題的意思是,阿里雲maven倉庫中,沒有你需要的依賴包。此時需要修改一下你的maven settings.xml鏡像地址。
還有一種可能是因爲,多模塊化工程。某一個模塊依賴另一個模塊,那個模塊沒有install。解決方式是,依賴的模塊進行 mvn clean install 就行了

先執行mvn clean,然後再執行一下mvn package -U ,第二個命令能治百病

mvn clean install -Dmaven.test.skip=true -U試一下
不行就手動刪除 .m2下被緩存的包

 

keyword斷言增加version條件判斷

        // keyword判斷,0923版本需要改爲urlencode傳參,((%[0-9A-Fa-f]{2}){2})+
        // %E5%A4%A9%E5%9D%91%E9%B9%B0%E7%8C%8E
        // 將需要轉碼的字符轉爲16進制,然後從右到左,取4位(不足4位直接處理),每2位做一位,前面加上%,編碼成%XY格式,但考慮到用戶輸入的query可能爲abc 123 《我愛我家》 親愛的,熱愛的特殊字符
        String logVersion = json.getString("version");
        String minVersion = "8.1.9";
        int s = 0;
        try {
            s = compareVersion(logVersion, minVersion);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (json.containsKey("keyword")) {
            String keyword = json.getString("keyword");
            if (TextUtils.isEmpty(keyword)) {
                System.err.println("第" + count + "條日誌,keyword客戶端傳參value爲空,結果爲" + keyword + ",BUG BUG BUG!!!");
                // 記錄error級別的信息
                logger.error("error.log======第" + count + "條日誌,keyword客戶端傳參value爲空,結果爲" + keyword + ",BUG BUG BUG!!!");
            } else if (s >= 0 && !(keyword.matches("((%[0-9A-Fa-f]{2}){2})+") || keyword.matches("[0-9a-zA-Z]+") || !keyword.matches("[^\\x00-\\xff]*[a-zA-Z0-9]*"))) {
                System.err.println("第" + count + "條日誌,keyword客戶端傳參不符合正則規則,沒有urlencode,結果爲" + keyword + ",BUG BUG BUG!!!");
                // 記錄error級別的信息
                logger.error("error.log======第" + count + "條日誌,keyword客戶端傳參不符合正則規則,沒有urlencode,結果爲" + keyword + ",BUG BUG BUG!!!");

//                logger.error("第" + count + "條日誌,keyword客戶端傳參不符合正則規則,沒有urlencode,結果爲" + keyword + ",BUG BUG BUG!!!");


                /**
                 * 2019-10-28新增釘釘機器人接入報警,打印出問題的參數以及在數據庫查詢出的原始日誌,便於排查
                 */

                sb.append("第" + count + "條日誌,keyword客戶端傳參不符合正則規則,沒有urlencode,結果爲" + keyword + ",BUG BUG BUG!!!" +
                        currentTime + "日" + clientTimeStamp + ",第【" + count + "】條數據," +
                        "ytsoku.content.origialParam的json傳參日誌爲=======" + json);

                if (!sb.toString().isEmpty()) {
                    try {
                        // 機器人報警,此處填寫自己創建機器人時的token
                        DingTalkUtil.alert("750e544acab37373edf5d872d7607738c8b29c6a133428ab599c51ea120aeccb", sb.toString(), null, false);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            } else if (s < 0 && !keyword.matches("\\S")) {
                System.err.println("第" + count + "條日誌,keyword客戶端傳參不符合正則規則,沒有urlencode,結果爲" + keyword + ",BUG BUG BUG!!!");

            } else {
                System.out.println("第" + count + "條日誌,keyword客戶端傳參正確,校驗通過~~~");

                // 記錄info級別的信息
                logger.info("log======第" + count + "條日誌,keyword客戶端傳參正確,校驗通過~~~");
            }

        } else {
            System.err.println("第" + count + "條日誌,客戶端傳參缺少【keyword】數據節點,BUG BUG BUG!!!");
            // 記錄error級別的信息
            logger.error("error.log======第" + count + "條日誌,客戶端傳參缺少【keyword】數據節點,BUG BUG BUG!!!");

            //2019-10-28新增釘釘機器人接入報警,打印出問題的參數以及在數據庫查詢出的原始日誌,便於排查
            sb.append("第" + count + "條日誌,客戶端傳參缺少【keyword】數據節點,BUG BUG BUG!!!" +
                    currentTime + "日" + clientTimeStamp + ",第【" + count + "】條數據," +
                    "ytsoku.content.origialParam的json傳參日誌爲=======" + json);

            if (!sb.toString().isEmpty()) {
                try {
                    // 機器人報警,此處填寫自己創建機器人時的token
                    DingTalkUtil.alert("750e544acab37373edf5d872d7607738c8b29c6a133428ab599c51ea120aeccb", sb.toString(), null, false);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

 

/**
 * 比較版本號的大小,前者大則返回一個正數,後者大返回一個負數,相等則返回0
 *
 * @param logVersion
 * @param minVersion
 * @return
 */
public static int compareVersion(String logVersion, String minVersion) throws Exception {
    if (logVersion == null || minVersion == null) {
        throw new Exception("compareVersion error:illegal params.");
    }
    String[] versionArray1 = logVersion.split("\\.");//注意此處爲正則匹配,不能用".";
    String[] versionArray2 = minVersion.split("\\.");
    int idx = 0;
    int minLength = Math.min(versionArray1.length, versionArray2.length);//取最小長度值,如8.5和8.5.1版本比較,取前者長度
    int diff = 0;
    // 按小數點拆分的長度比較,如8.1.0和8.11.0
    while (idx < minLength
            && (diff = versionArray1[idx].length() - versionArray2[idx].length()) == 0//先比較長度
            && (diff = versionArray1[idx].compareTo(versionArray2[idx])) == 0) {//再比較字符
        // while裏先加再用
        ++idx;
    }
    //如果已經分出大小,則直接返回,如果未分出大小,則再比較位數,有子版本的爲大;如果logVersion<minVersion 則返回<0(三目運算),否則logVersion>minVersion則爲正數
    diff = (diff != 0) ? diff : versionArray1.length - versionArray2.length;
    if (diff == 0) {

    }
    return diff;
}

public static void main(String args[]) {

    try {
        int in = compareVersion("8.8.5", "8.33.6");
        System.out.println("前者比後者大:" + in + " ==");
    } catch (Exception e) {

        e.printStackTrace();
    }
    try {
        int in = compareVersion("8.2.1", "8.1.11");
        System.out.println("後者比前者大:" + in + " ==");
    } catch (Exception e) {
        e.printStackTrace();
    }

}

如遇

Exception in thread "main" java.lang.StackOverflowError
    at com.alibaba.newcpw.sdksearch.logDeal.sbCommonPrint.sbCommonParam(sbCommonPrint.java:37)
    at com.alibaba.newcpw.sdksearch.logDeal.sbCommonPrint.sbCommonParam(sbCommonPrint.java:37)
    at com.alibaba.newcpw.sdksearch.logDeal.sbCommonPrint.sbCommonParam(sbCommonPrint.java:37)

StackOverflowError
原因 : 函數調用棧太深了,注意代碼中是否有了循環調用方法而無法退出的情況

原理
StackOverflowError 是一個java中常出現的錯誤:在jvm運行時的數據區域中有一個java虛擬機棧,當執行java方法時會進行壓棧彈棧的操作。在棧中會保存局部變量,操作數棧,方法出口等等。jvm規定了棧的最大深度,當執行時棧的深度大於了規定的深度,就會拋出StackOverflowError錯誤
 

如何解決 StackOverFlowError?

引發 StackOverFlowError 的常見原因有以下幾種:

  • 無限遞歸循環調用(最常見)。

  • 執行了大量方法,導致線程棧空間耗盡。

  • 方法內聲明瞭海量的局部變量。

  • native 代碼有棧上分配的邏輯,並且要求的內存還不小,比如 java.net.SocketInputStream.read0 會在棧上要求分配一個 64KB 的緩存(64位 Linux)。

除了程序拋出 StackOverflowError 錯誤以外,還有兩種定位棧溢出的方法:

  • 進程突然消失,但是留下了 crash 日誌,可以檢查 crash 日誌裏當前線程的 stack 範圍,以及 RSP 寄存器的值。如果 RSP 寄存器的值超出這個 stack 範圍,那就說明是棧溢出了。

  • 如果沒有 crash 日誌,那隻能通過 coredump 進行分析。在進程運行前,先執行 ulimit -c unlimited,當進程掛掉之後,會產生一個 core.[pid] 的文件,然後再通過 jstack $JAVA_HOME/bin/java core.[pid] 來看輸出的棧。如果正常輸出了,那就可以看是否存在很長的調用棧的線程,當然還有可能沒有正常輸出的,因爲 jstack 的這條從 core 文件抓棧的命令其實是基於 Serviceability Agent 實現的,而 SA 在某些版本里有 Bug。

常見的解決方法包括以下幾種:

  • 修復引發無限遞歸調用的異常代碼, 通過程序拋出的異常堆棧,找出不斷重複的代碼行,按圖索驥,修復無限遞歸 Bug。

  • 排查是否存在類之間的循環依賴。

  • 排查是否存在在一個類中對當前類進行實例化,並作爲該類的實例變量。

  • 通過 JVM 啓動參數 -Xss 增加線程棧內存空間, 某些正常使用場景需要執行大量方法或包含大量局部變量,這時可以適當地提高線程棧空間限制,例如通過配置 -Xss2m 將線程棧空間調整爲 2 mb。

 

 

 

 

待續

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章