Skip to content

Commit

Permalink
Fix of JVM crush with JDK 9
Browse files Browse the repository at this point in the history
  • Loading branch information
plokhotnyuk committed Feb 24, 2018
1 parent d7b761b commit 4d7bf22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ object UnsafeUtils {
}.getOrElse((null, 0L, 0L))

private[jsoniter_scala] final def getLatin1Array(s: String): Array[Byte] =
if (stringCoderOffset == 0 || unsafe.getByte(s, stringCoderOffset) != 0) null
if (stringCoderOffset == 0 || (s eq null) || unsafe.getByte(s, stringCoderOffset) != 0) null
else unsafe.getObject(s, stringValueOffset).asInstanceOf[Array[Byte]]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.github.plokhotnyuk.jsoniter_scala.core

import org.scalatest.{Matchers, WordSpec}

class UnsafeUtilsSpec extends WordSpec with Matchers {
"UnsafeUtils" should {
"be safe when getLatin1Array is called" in {
UnsafeUtils.getLatin1Array("s")
UnsafeUtils.getLatin1Array(null) shouldBe null
}
}
}

0 comments on commit 4d7bf22

Please sign in to comment.