Merge OS 4.6 OS 4.7

Conflicts:
- .ci/api-current.txt - Kept existing version on 4.7 as I'm about to regenerate the file
This commit is contained in:
Joseph Zuniga-Daly 2020-09-01 15:28:37 +01:00
commit eecc294820
4 changed files with 47 additions and 15 deletions

View File

@ -408,24 +408,24 @@ class CordaRPCClientReconnectionTest {
val completedCounter = AtomicInteger(0)
flowHandle0.returnValue.doOnComplete {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
flowHandle1!!.returnValue.doOnComplete {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
flowHandle0.returnValue.thenMatch({
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}, {})
flowHandle1.returnValue.thenMatch({
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}, {})
flowHandle0.returnValue.toCompletableFuture().thenApply {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
flowHandle1.returnValue.toCompletableFuture().thenApply {
completedCounter.incrementAndGet()
completedCounter.getAndIncrement()
}
node.stop()
@ -469,13 +469,13 @@ class CordaRPCClientReconnectionTest {
val clientId = UUID.randomUUID().toString()
val flowHandle = rpcOps.startFlowWithClientId(clientId, ::ThrowingFlow)
var erroredCounter = 0
val erroredCounter = AtomicInteger(0)
flowHandle.returnValue.doOnError {
erroredCounter++
erroredCounter.getAndIncrement()
}
flowHandle.returnValue.toCompletableFuture().exceptionally {
erroredCounter++
erroredCounter.getAndIncrement()
}
node.stop()
@ -489,7 +489,7 @@ class CordaRPCClientReconnectionTest {
}
sleep(1000)
assertEquals(2, erroredCounter)
assertEquals(2, erroredCounter.get())
assertThat(rpcOps.reconnectingRPCConnection.isClosed())
}
}

View File

@ -92,8 +92,9 @@ open class SharedNodeCmdLineOptions {
return """
Unable to load the node config file from '$configFile'.
${cause?.message?.let { "Cause: $it" } ?: ""}
Try setting the --base-directory flag to change which directory the node
Ensure that the [COMMAND] precedes all options. Alternatively, try
setting the --base-directory flag to change which directory the node
is looking in, or use the --config-file flag to specify it explicitly.
""".trimIndent()
}

View File

@ -41,17 +41,20 @@ class NodeInfoWatcher(private val nodePath: Path,
private val logger = contextLogger()
// TODO This method doesn't belong in this class
fun saveToFile(path: Path, nodeInfoAndSigned: NodeInfoAndSigned) {
fun saveToFile(path: Path, nodeInfoAndSigned: NodeInfoAndSigned): Path {
// By using the hash of the node's first name we ensure:
// 1) node info files for the same node map to the same filename and thus avoid having duplicate files for
// the same node
// 2) avoid having to deal with characters in the X.500 name which are incompatible with the local filesystem
val fileNameHash = nodeInfoAndSigned.nodeInfo.legalIdentities[0].name.serialize().hash
val target = path / "${NodeInfoFilesCopier.NODE_INFO_FILE_NAME_PREFIX}$fileNameHash"
nodeInfoAndSigned
.signed
.serialize()
.open()
.copyTo(path / "${NodeInfoFilesCopier.NODE_INFO_FILE_NAME_PREFIX}$fileNameHash", REPLACE_EXISTING)
.copyTo(target, REPLACE_EXISTING)
return target
}
}
@ -85,6 +88,7 @@ class NodeInfoWatcher(private val nodePath: Path,
logger.debug { "Examining $it" }
true
}
.filter { !it.toString().endsWith(".tmp") }
.filter { it.isRegularFile() }
.filter { file ->
val lastModifiedTime = file.lastModifiedTime()

View File

@ -7,11 +7,11 @@ import net.corda.core.internal.createDirectories
import net.corda.core.internal.div
import net.corda.core.internal.size
import net.corda.core.node.services.KeyManagementService
import net.corda.coretesting.internal.createNodeInfoAndSigned
import net.corda.nodeapi.internal.NodeInfoAndSigned
import net.corda.nodeapi.internal.network.NodeInfoFilesCopier
import net.corda.testing.core.ALICE_NAME
import net.corda.testing.core.SerializationEnvironmentRule
import net.corda.coretesting.internal.createNodeInfoAndSigned
import net.corda.testing.node.internal.MockKeyManagementService
import net.corda.testing.node.makeTestIdentityService
import org.assertj.core.api.Assertions.assertThat
@ -21,7 +21,9 @@ import org.junit.Test
import org.junit.rules.TemporaryFolder
import rx.observers.TestSubscriber
import rx.schedulers.TestScheduler
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import java.util.concurrent.TimeUnit
import kotlin.test.assertEquals
import kotlin.test.assertTrue
@ -132,6 +134,31 @@ class NodeInfoWatcherTest {
}
}
@Test(timeout=300_000)
fun `ignore tmp files`() {
nodeInfoPath.createDirectories()
// Start polling with an empty folder.
val subscription = nodeInfoWatcher.nodeInfoUpdates().subscribe(testSubscriber)
try {
// Ensure the watch service is started.
advanceTime()
// create file
// boohoo, we shouldn't create real files, instead mock Path
val file = NodeInfoWatcher.saveToFile(nodeInfoPath, nodeInfoAndSigned)
Files.move(file, Paths.get("$file.tmp"))
advanceTime()
// Check no nodeInfos are read.
assertEquals(0, testSubscriber.onNextEvents.distinct().flatten().size)
} finally {
subscription.unsubscribe()
}
}
private fun advanceTime() {
scheduler.advanceTimeBy(1, TimeUnit.MINUTES)
}