将java插件从3.5升级到3.6时,构建会卡在文件上,永远不会超时。这个问题也存在于3.7。
中它看起来类似于我最近遇到的另一个问题,但它似乎并没有实际超时或崩溃。构建永远不会停止。 Sonarqube thrashing when doing AST scan on old Apache Axis 1.2.1 generated code
是否有一种简单的方法可以确定哪个规则可能导致日志记录问题或仅添加超时?
更新 以下是一些重现问题的代码
public class SonarIssue {
public SonarIssue() {
super();
}
private List getOfficials(int quarterId, int categoryCode, boolean current) throws RuntimeException {
PreparedStatement preparedStatement = null;
Connection connection = null;
ResultSet resultSet = null;
boolean newTransaction = false;
ArrayList list = new ArrayList();
try {
String sql = "SELECT DISTINCT " + " o.client_ofcl_fst_nm, " + " o.client_ofcl_lst_nm, "
+ " o.client_ofcl_ttl_nm_e, " + " o.client_ofcl_ttl_nm_f, " + " o.client_ofcl_seq_no, "
+ " o.client_ofcl_sctr_nm_e, " + " o.client_ofcl_sctr_nm_f, " + " o.client2_ofcl_ctgry_cd, "
+ " o.client_ofcl_end_dt " + "FROM client_ofcl_tbl o, " + " client2_rptg_qtr_tbl q "
+ "WHERE q.client2_rptg_qtr_seq_no = ? " + " AND o.client2_ofcl_ctgry_cd = ? "
+ " AND ((o.client_ofcl_strt_dt <= " + " q.client2_rptg_qtr_end_dt) "
+ " OR o.client_ofcl_strt_dt IS NULL)" + " AND ((o.client2_ofcl_dsclsr_lst_dt >= "
+ " q.client2_rptg_qtr_strt_dt) " + " OR o.client2_ofcl_dsclsr_lst_dt IS NULL)";
if (current) {
sql = sql + " AND ((o.client_ofcl_end_dt >= " + " q.client2_rptg_qtr_strt_dt) "
+ " OR o.client_ofcl_end_dt IS NULL)";
} else {
sql = sql + " AND o.client_ofcl_end_dt < " + " q.client2_rptg_qtr_strt_dt ";
}
sql = sql + " ORDER BY nlssort(o.client_ofcl_lst_nm, " + " 'NLS_SORT = FRENCH'), "
+ " nlssort(o.client_ofcl_fst_nm, " + " 'NLS_SORT = FRENCH') ";
connection = getConnection();
preparedStatement = connection.prepareStatement(sql);
preparedStatement.setInt(1, quarterId);
preparedStatement.setInt(2, categoryCode);
resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
SonarqubeOfficial official = new SonarqubeOfficial();
official.setFirstName(resultSet.getString(1));
official.setLastName(resultSet.getString(2));
official.setTitleEn(resultSet.getString(3));
official.setTitleFr(resultSet.getString(4));
official.setOfficialId(resultSet.getInt(5));
official.setSectorEn(resultSet.getString(6));
official.setSectorFr(resultSet.getString(7));
official.setCategoryCd(resultSet.getInt(8));
// Check if each official has an expense
if (hasExpensesForQuarter(Integer.toString(official.getOfficialId()), quarterId)) {
official.setHasExpenses(true);
} else {
official.setHasExpenses(false);
}
list.add(official);
}
} catch (SQLException sqle) {
RuntimeException exception = new RuntimeException("error.database.default", sqle);
throw exception;
} finally {
if (newTransaction) {
// TODO stop a transaction
} else {
closeResources(new Object[]{resultSet, preparedStatement});
}
}
return list;
}
public boolean hasExpensesForQuarter(String officialId, int quarterId) throws RuntimeException {
return true;
}
// below are methods that are from libraries. Since these are default return values, the code would never actually
// work.
public Connection getConnection() {
return null;
}
public static void closeResources(Object[] connResources) {
for (Object connResource : connResources) {
if (connResource != null) {
try {
if (connResource instanceof java.sql.Connection) {
((Connection) connResource).close();
} else if (connResource instanceof java.sql.ResultSet) {
((ResultSet) connResource).close();
} else if (connResource instanceof java.sql.Statement) {
((Statement) connResource).close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
}
public class SonarqubeOfficial implements Serializable {
private static final long serialVersionUID = 5888521931094795053L;
private int officialId;
private int categoryCd;
private String lastName;
private String firstName;
private String titleEn;
private String titleFr;
private String sectorEn;
private String sectorFr;
private boolean hasExpenses;
private boolean isReporting;
private String lastReportingDate;
private String startDate;
private String endDate;
private String lastModifiedUserName;
// getters and setters
}
(请原谅格式化)
在卡住之前打印的堆栈跟踪看起来像这样:
Exception in thread "main" java.lang.StackOverflowError
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.leftOperand(BinaryExpressionTreeImpl.java:52)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBinaryExpression(BaseTreeVisitor.java:208)
at org.sonar.java.model.expression.BinaryExpressionTreeImpl.accept(BinaryExpressionTreeImpl.java:72)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitVariable(BaseTreeVisitor.java:292)
at org.sonar.java.model.declaration.VariableTreeImpl.accept(VariableTreeImpl.java:179)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBlock(BaseTreeVisitor.java:85)
at org.sonar.java.model.statement.BlockTreeImpl.accept(BlockTreeImpl.java:77)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitTryStatement(BaseTreeVisitor.java:190)
at org.sonar.java.model.statement.TryStatementTreeImpl.accept(TryStatementTreeImpl.java:172)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:37)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitBlock(BaseTreeVisitor.java:85)
at org.sonar.java.model.statement.BlockTreeImpl.accept(BlockTreeImpl.java:77)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.scan(BaseTreeVisitor.java:43)
at org.sonar.plugins.java.api.tree.BaseTreeVisitor.visitMethod(BaseTreeVisitor.java:80)
at org.sonar.java.model.declaration.MethodTreeImpl.accept(MethodTreeImpl.java:215)
at org.sonar.java.checks.helpers.ReassignmentFinder.getReassignments(ReassignmentFinder.java:84)
at org.sonar.java.checks.helpers.ReassignmentFinder.getClosestReassignmentOrDeclarationExpression(ReassignmentFinder.java:58)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:136)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:128)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleStringConcatenation(PreparedStatementAndResultSetCheck.java:144)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.getNumberQuery(PreparedStatementAndResultSetCheck.java:130)
at org.sonar.java.checks.PreparedStatementAndResultSetCheck.handleVariableUsedAsQuery(PreparedStatementAndResultSetCheck.java:138)
答案 0 :(得分:4)
我正在使用SonarQube 5.1.2并且在类 synchronized (MyClass.class) {
...
}
和PreparedStatement
中有一个非常相似的StackOverflowError。
作为一种解决方法,我禁用规则 S2695 ,直到它们再次运行。
答案 1 :(得分:-1)
我们使用SonarQube 4.5.6和Java Plugin 3.7获得了相同的StackOverflowError。 我们按照建议禁用了规则S2695。 我们正在等待Java插件3.9(2015年12月23日RD)。
为我们所有人嫁给Chrustmas。