0

我将 Sonar 与 Ant 一起使用,导入 Cobertura 和单元测试结果,并通过设置“Sonar + FindBugs”运行代码质量分析。我以前能够使用 Sonar 分析我的(大型)项目。我不知道,也许我做了一些改变,但现在分析没有完成。Sonar 已成功导入 Cobertura 报告,然后它尝试执行装饰器,但它只是挂起(几个小时):

p.PhasesTimeProfiler - 执行装饰器...

我已经在 Windows7 和 RHEL 6 机器上对此进行了测试。我已将 ANT java 堆增加到 2048M。使用较小的设置,我通常会在某些时候得到一个超出 Java 堆的异常。进程当前正在运行,进程正在使用2266M的内存。

有任何想法吗?:)

Sonar 挂起前的最后几行如下(调试模式):

[sonar:sonar] 10:25:24.348 DEBUG raphMetricAggregator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.350 DEBUG emDashBoardDecorator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.505 DEBUG raphMetricAggregator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.505 DEBUG emDashBoardDecorator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.986 DEBUG raphMetricAggregator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.986 DEBUG emDashBoardDecorator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.994 DEBUG raphMetricAggregator - Checking for resource type: CLA
[sonar:sonar] 10:25:24.995 DEBUG emDashBoardDecorator - Checking for resource type: CLA
[sonar:sonar] 10:25:25.206 DEBUG raphMetricAggregator - Checking for resource type: CLA
[sonar:sonar] 10:25:25.206 DEBUG emDashBoardDecorator - Checking for resource type: CLA
[sonar:sonar] 10:25:25.214 DEBUG raphMetricAggregator - Checking for resource type: CLA
[sonar:sonar] 10:25:25.214 DEBUG emDashBoardDecorator - Checking for resource type: CLA

在 Sonar Ant 目标中将 SQL 设置为详细的情况下,它挂起的最终 SQL 语句是:

[sonar:sonar] 10:00:31.855 DEBUG    org.hibernate.SQL - select snapshot0_.id as
id7_, snapshot0_.build_date as build2_7_, snapshot0_.created_at as created3_7_,
snapshot0_.depth as depth7_, snapshot0_.islast as islast7_, snapshot0_.parent_sn
apshot_id as parent6_7_, snapshot0_.path as path7_, snapshot0_.period1_date as p
eriod8_7_, snapshot0_.period1_mode as period9_7_, snapshot0_.period1_param as pe
riod10_7_, snapshot0_.period2_date as period11_7_, snapshot0_.period2_mode as pe
riod12_7_, snapshot0_.period2_param as period13_7_, snapshot0_.period3_date as p
eriod14_7_, snapshot0_.period3_mode as period15_7_, snapshot0_.period3_param as
period16_7_, snapshot0_.period4_date as period17_7_, snapshot0_.period4_mode as
period18_7_, snapshot0_.period4_param as period19_7_, snapshot0_.period5_date as
 period20_7_, snapshot0_.period5_mode as period21_7_, snapshot0_.period5_param a
s period22_7_, snapshot0_.purge_status as purge23_7_, snapshot0_.qualifier as qu
alifier7_, snapshot0_.project_id as project25_7_, snapshot0_.root_snapshot_id as
 root26_7_, snapshot0_.root_project_id as root27_7_, snapshot0_.scope as scope7_
, snapshot0_.status as status7_, snapshot0_.version as version7_ from snapshots
snapshot0_ where snapshot0_.islast=? and snapshot0_.project_id=(select resourcem
o1_.id from projects resourcemo1_ where resourcemo1_.kee=?)
[sonar:sonar] 10:00:31.899 DEBUG    org.hibernate.SQL - select snapshotso0_.id a
s id13_, snapshotso0_.data as data13_, snapshotso0_.snapshot_id as snapshot3_13_
 from snapshot_sources snapshotso0_ where snapshotso0_.snapshot_id=?

在第二次运行中,我也得到了这个:

[sonar:sonar] 11:16:40.149 DEBUG b.b.JdbcDriverHolder - To prevent a memory leak
, the JDBC Driver [com.mysql.jdbc.Driver] has been forcibly deregistered

当我没有增加 java 堆大小并通过 Jenkins 执行 Sonar Ant 目标时,我得到以下信息:

java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:2746)
    at java.util.ArrayList.ensureCapacity(ArrayList.java:187)
    at java.util.ArrayList.add(ArrayList.java:378)
    at     org.sonar.plugins.core.timemachine.ViolationTrackingDecorator.mapViolations(ViolationTrackingDecorator.java:131)
at org.sonar.plugins.core.timemachine.ViolationTrackingDecorator.decorate(ViolationTrackingDecorator.java:70)
at org.sonar.batch.phases.DecoratorsExecutor.executeDecorator(DecoratorsExecutor.java:79)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:70)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:63)
at org.sonar.batch.phases.DecoratorsExecutor.decorateResource(DecoratorsExecutor.java:63)

如果我将 Ant 增加为使用 2048M,则不会出现上述 java 堆空间问题,但随后装饰器挂起,如第一个错误输出所示。

4

1 回答 1

1

我很遗憾地报告,如果不从 MySQL 数据库中删除整个项目,我就无法解决这个问题。我注意到在它开始挂起后我做了两个改变。1) 我似乎将项目密钥更改为其他内容,2) 我已将质量配置文件从默认更改为“Sonar + findbugs”。

声纳在 4 次运行(即 4 天)后停止工作,所以我会从现在开始看看这是否有效,而无需更改我的初始设置。今天早上的第一次运行顺利。

于 2012-10-11T06:38:16.367 回答