Also attach traces to ownership errors from compact() and bifurcate()

This commit is contained in:
Chris Vest 2021-03-06 11:14:00 +01:00
parent 264746d583
commit bf80061335

View File

@ -503,7 +503,7 @@ class MemSegBuffer extends RcSupport<Buffer, MemSegBuffer> implements Buffer, Re
@Override
public Buffer bifurcate() {
if (!isOwned()) {
throw new IllegalStateException("Cannot bifurcate a buffer that is not owned.");
throw attachTrace(new IllegalStateException("Cannot bifurcate a buffer that is not owned."));
}
var drop = unsafeGetDrop();
if (seg.ownerThread() != null) {
@ -535,7 +535,7 @@ class MemSegBuffer extends RcSupport<Buffer, MemSegBuffer> implements Buffer, Re
@Override
public void compact() {
if (!isOwned()) {
throw new IllegalStateException("Buffer must be owned in order to compact.");
throw attachTrace(new IllegalStateException("Buffer must be owned in order to compact."));
}
if (readOnly()) {
throw new IllegalStateException("Buffer must be writable in order to compact, but was read-only.");