fix envelope formats

This commit is contained in:
Alexander Nozik 2019-12-01 15:00:27 +03:00
parent 2e643287ef
commit 76e7f47528
5 changed files with 11 additions and 14 deletions

View File

@ -1,9 +1,9 @@
import scientifik.ScientifikExtension import scientifik.ScientifikExtension
plugins { plugins {
id("scientifik.mpp") version "0.2.5" apply false id("scientifik.mpp") version "0.2.6" apply false
id("scientifik.jvm") version "0.2.5" apply false id("scientifik.jvm") version "0.2.6" apply false
id("scientifik.publish") version "0.2.5" apply false id("scientifik.publish") version "0.2.6" apply false
} }
val dataforgeVersion by extra("0.1.5-dev-3") val dataforgeVersion by extra("0.1.5-dev-3")

View File

@ -9,7 +9,7 @@ scientifik {
//withIO() //withIO()
} }
val ioVersion by rootProject.extra("0.2.0-npm-dev-2") val ioVersion by rootProject.extra("0.2.0-npm-dev-3")
kotlin { kotlin {
sourceSets { sourceSets {

View File

@ -67,7 +67,7 @@ class TaggedEnvelopeFormat(
val metaFormat = io.metaFormat(tag.metaFormatKey) val metaFormat = io.metaFormat(tag.metaFormatKey)
?: error("Meta format with key ${tag.metaFormatKey} not found") ?: error("Meta format with key ${tag.metaFormatKey} not found")
val meta: Meta = limit(tag.metaSize.toInt()).use { val meta: Meta = limit(tag.metaSize.toInt()).run {
metaFormat.run { metaFormat.run {
readObject() readObject()
} }

View File

@ -46,7 +46,7 @@ class TaglessEnvelopeFormat(
writeProperty(META_LENGTH_PROPERTY, metaBytes.size + 2) writeProperty(META_LENGTH_PROPERTY, metaBytes.size + 2)
writeUtf8String(metaStart + "\r\n") writeUtf8String(metaStart + "\r\n")
writeBinary(metaBytes) writeBinary(metaBytes)
writeUtf8String("\r\n") writeRawString("\r\n")
} }
//Printing data //Printing data
@ -71,12 +71,9 @@ class TaglessEnvelopeFormat(
val (key, value) = match.destructured val (key, value) = match.destructured
properties[key] = value properties[key] = value
} }
try { //If can't read line, return envelope without data
line = readUtf8Line() if (eof()) return SimpleEnvelope(Meta.empty, null)
} catch (ex: EOFException) { line = readUtf8Line()
//If can't read line, return envelope without data
return SimpleEnvelope(Meta.empty, null)
}
} }
var meta: Meta = EmptyMeta var meta: Meta = EmptyMeta

View File

@ -24,7 +24,7 @@ class EnvelopeFormatTest {
fun testTaggedFormat(){ fun testTaggedFormat(){
TaggedEnvelopeFormat.run { TaggedEnvelopeFormat.run {
val byteArray = this.writeByteArray(envelope) val byteArray = this.writeByteArray(envelope)
println(byteArray.decodeToString()) //println(byteArray.decodeToString())
val res = readByteArray(byteArray) val res = readByteArray(byteArray)
assertEquals(envelope.meta,res.meta) assertEquals(envelope.meta,res.meta)
val double = res.data?.read { val double = res.data?.read {
@ -38,7 +38,7 @@ class EnvelopeFormatTest {
fun testTaglessFormat(){ fun testTaglessFormat(){
TaglessEnvelopeFormat.run { TaglessEnvelopeFormat.run {
val byteArray = writeByteArray(envelope) val byteArray = writeByteArray(envelope)
println(byteArray.decodeToString()) //println(byteArray.decodeToString())
val res = readByteArray(byteArray) val res = readByteArray(byteArray)
assertEquals(envelope.meta,res.meta) assertEquals(envelope.meta,res.meta)
val double = res.data?.read { val double = res.data?.read {