Sonarqube thrashing when doing AST scan on old Apache Axis 1.2.1 generated code

老子叫甜甜 提交于 2019-12-24 14:04:08

问题


On some code that was generated by Apache Axis 1.2.1, sonarqube started to have issues scanning it. It gets stuck on the file and then seems to eat up memory and keep running GC until it eventually stops.

It will log errors like the following

    Java Main Files AST scan...
    11 source files to be analyzed
    9/11 files analyzed, current is /bamboo-path/TestProjectWAR/src/main/java/com/example/sonar/bug/Contact.java
    9/11 files analyzed, current is /bamboo-path/TestProjectWAR/src/main/java/com/example/sonar/bug/Contact.java    
    [JOURNAL_FLUSHER] WARNING Journal flush operation took 13,241ms last 8 cycles average is 2,192ms
...
Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project TestProject: GC overhead limit exceeded -> [Help 1]

I believe this started after we updated to java plugin 3.3, but I'm not 100% on that.

Here's a paired down version of the code

public class Contact implements java.io.Serializable {
private java.lang.String cccCntctSeqNo;
private java.lang.Object __equalsCalc = null;

@Override
public synchronized boolean equals(java.lang.Object obj) {
    if (!(obj instanceof Contact)) {
        return false;
    }
    Contact other = (Contact) obj;
    if (obj == null) {
        return false;
    }
    if (this == obj) {
        return true;
    }
    if (__equalsCalc != null) {
        return (__equalsCalc == obj);
    }
    __equalsCalc = obj;
    boolean _equals;
    _equals = true
        && ((this.cccCntctSeqNo == null && other.getCccCntctSeqNo() == null) || (this.cccCntctSeqNo != null && this.cccCntctSeqNo
            .equals(other.getCccCntctSeqNo())))
    __equalsCalc = null;
    return _equals;
}

private boolean __hashCodeCalc = false;

@Override
public synchronized int hashCode() {
    if (__hashCodeCalc) {
        return 0;
    }
    __hashCodeCalc = true;
    int _hashCode = 1;
    if (getCccCntctSeqNo() != null) {
        _hashCode += getCccCntctSeqNo().hashCode();
    }
    __hashCodeCalc = false;
    return _hashCode;
}

}

Has anyone else come across this or found any work arounds?


回答1:


Seems like you are hitting this known issue : http://jira.sonarsource.com/browse/SONARJAVA-1063

Release containing the fix is about to happen.




回答2:


I had the same problem where it used to hung on Journal Flushing and ultimately timeout at whatever the value i set in Windbags Java default timeout in sonarqube.

I resolved this by using the following options while running the sonar man command:- MAVEN_OPTS="-Xms256m -Xmx4096m -XX:+UseSerialGC"

This has fixed the issue for me.



来源:https://stackoverflow.com/questions/30895150/sonarqube-thrashing-when-doing-ast-scan-on-old-apache-axis-1-2-1-generated-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!