From 5cf987a9e9cab3e9ec3d2a8acc335a85f2637df0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 9 Jun 2018 15:51:11 +1200 Subject: Fix various issues --- src/org/traccar/helper/BufferUtil.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/org/traccar/helper') diff --git a/src/org/traccar/helper/BufferUtil.java b/src/org/traccar/helper/BufferUtil.java index 81a081182..5606dba8a 100644 --- a/src/org/traccar/helper/BufferUtil.java +++ b/src/org/traccar/helper/BufferUtil.java @@ -28,8 +28,12 @@ public final class BufferUtil { } public static int indexOf(String needle, ByteBuf haystack) { - return ByteBufUtil.indexOf( - Unpooled.wrappedBuffer(needle.getBytes(StandardCharsets.US_ASCII)), haystack); + ByteBuf needleBuffer = Unpooled.wrappedBuffer(needle.getBytes(StandardCharsets.US_ASCII)); + try { + return ByteBufUtil.indexOf(needleBuffer, haystack); + } finally { + needleBuffer.release(); + } } public static int indexOf(String needle, ByteBuf haystack, int startIndex, int endIndex) { -- cgit v1.2.3