Merge pull request #1544 from corda/m4ksio_gradle_no_o_fix

Avoid ArrayOutOfBound exception in Gradle
This commit is contained in:
Maksymilian Pawlak 2017-10-23 13:24:31 +01:00 committed by GitHub
commit 931ab120fc

View File

@ -3,6 +3,7 @@ package net.corda.plugins
import com.typesafe.config.*
import net.corda.cordform.CordformNode
import org.bouncycastle.asn1.x500.X500Name
import org.bouncycastle.asn1.x500.RDN
import org.bouncycastle.asn1.x500.style.BCStyle
import org.gradle.api.Project
import java.io.File
@ -117,7 +118,12 @@ class Node(private val project: Project) : CordformNode() {
}
val dirName = try {
X500Name(name).getRDNs(BCStyle.O).first().first.value.toString()
val o = X500Name(name).getRDNs(BCStyle.O)
if (o.size > 0) {
o.first().first.value.toString()
} else {
name
}
} catch(_ : IllegalArgumentException) {
// Can't parse as an X500 name, use the full string
name