Prevent the node from starting if running on a version of Java with the empty Path bug (#83)

This commit is contained in:
Shams Asari 2016-12-28 15:07:18 +00:00
parent 021bcb0628
commit e34f33785f

View File

@ -34,6 +34,8 @@ fun printBasicNodeInfo(description: String, info: String? = null) {
}
fun main(args: Array<String>) {
checkJavaVersion()
val startTime = System.currentTimeMillis()
val parser = OptionParser()
@ -115,9 +117,24 @@ fun main(args: Array<String>) {
exitProcess(0)
}
private fun checkJavaVersion() {
// Check we're not running a version of Java with a known bug: https://github.com/corda/corda/issues/83
try {
Paths.get("").normalize()
} catch (e: ArrayIndexOutOfBoundsException) {
println("""
You are using a version of Java that is not supported (${System.getProperty("java.version")}). Please upgrade to the latest version.
Corda will now exit...""")
exitProcess(1)
}
}
private fun printPluginsAndServices(node: Node) {
node.configuration.extraAdvertisedServiceIds.let { if (it.isNotEmpty()) printBasicNodeInfo("Providing network services", it) }
val plugins = node.pluginRegistries.map { it.javaClass.name }.filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") }.map { it.substringBefore('$') }
val plugins = node.pluginRegistries
.map { it.javaClass.name }
.filterNot { it.startsWith("net.corda.node.") || it.startsWith("net.corda.core.") }
.map { it.substringBefore('$') }
if (plugins.isNotEmpty())
printBasicNodeInfo("Loaded plugins", plugins.joinToString())
}