Skip to content

Commit d8d7b69

Browse files
committed
Merge pull request #22443 from rjernst/disable_assertions
Use tests.asserts flag to allow disabling assertions
1 parent 5cbc294 commit d8d7b69

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,9 @@ class BuildPlugin implements Plugin<Project> {
509509
}
510510
}
511511

512-
// System assertions (-esa) are disabled for now because of what looks like a
513-
// JDK bug triggered by Groovy on JDK7. We should look at re-enabling system
514-
// assertions when we upgrade to a new version of Groovy (currently 2.4.4) or
515-
// require JDK8. See https://issues.apache.org/jira/browse/GROOVY-7528.
516-
enableSystemAssertions false
512+
boolean assertionsEnabled = Boolean.parseBoolean(System.getProperty('tests.asserts', 'true'))
513+
enableSystemAssertions assertionsEnabled
514+
enableAssertions assertionsEnabled
517515

518516
testLogging {
519517
showNumFailuresAtEnd 25

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/ClusterConfiguration.groovy

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,10 @@ class ClusterConfiguration {
7272
boolean useMinimumMasterNodes = true
7373

7474
@Input
75-
String jvmArgs = "-ea" +
76-
" " + "-Xms" + System.getProperty('tests.heap.size', '512m') +
75+
String jvmArgs = "-Xms" + System.getProperty('tests.heap.size', '512m') +
7776
" " + "-Xmx" + System.getProperty('tests.heap.size', '512m') +
7877
" " + System.getProperty('tests.jvm.argline', '')
7978

80-
8179
/**
8280
* A closure to call which returns the unicast host to connect to for cluster formation.
8381
*

buildSrc/src/main/groovy/org/elasticsearch/gradle/test/NodeInfo.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ class NodeInfo {
151151
args.addAll("-E", "node.portsfile=true")
152152
String collectedSystemProperties = config.systemProperties.collect { key, value -> "-D${key}=${value}" }.join(" ")
153153
String esJavaOpts = config.jvmArgs.isEmpty() ? collectedSystemProperties : collectedSystemProperties + " " + config.jvmArgs
154+
if (Boolean.parseBoolean(System.getProperty('tests.asserts', 'true'))) {
155+
esJavaOpts += " -ea -esa"
156+
}
154157
env.put('ES_JAVA_OPTS', esJavaOpts)
155158
for (Map.Entry<String, String> property : System.properties.entrySet()) {
156159
if (property.key.startsWith('tests.es.')) {

0 commit comments

Comments
 (0)