From eaee4350b7f56c9d8ca3a802083baab910b0b1b8 Mon Sep 17 00:00:00 2001 From: Chris Vest Date: Tue, 1 Jun 2021 11:20:58 +0200 Subject: [PATCH] Make MemSegBuffer.compact throw correct exception when read-only --- .../src/main/java/io/netty/buffer/api/memseg/MemSegBuffer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buffer-memseg/src/main/java/io/netty/buffer/api/memseg/MemSegBuffer.java b/buffer-memseg/src/main/java/io/netty/buffer/api/memseg/MemSegBuffer.java index e347dd6..c181e48 100644 --- a/buffer-memseg/src/main/java/io/netty/buffer/api/memseg/MemSegBuffer.java +++ b/buffer-memseg/src/main/java/io/netty/buffer/api/memseg/MemSegBuffer.java @@ -17,6 +17,7 @@ package io.netty.buffer.api.memseg; import io.netty.buffer.ByteBuf; import io.netty.buffer.api.BufferAllocator; +import io.netty.buffer.api.BufferReadOnlyException; import io.netty.buffer.api.adaptor.BufferIntegratable; import io.netty.buffer.api.adaptor.ByteBufAdaptor; import io.netty.buffer.api.adaptor.ByteBufAllocatorAdaptor; @@ -618,7 +619,7 @@ class MemSegBuffer extends ResourceSupport implements Buff 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."); + throw new BufferReadOnlyException("Buffer must be writable in order to compact, but was read-only."); } int distance = roff; if (distance == 0) {