From: Robert Varga Date: Wed, 30 Aug 2023 14:48:38 +0000 (+0200) Subject: Make MemoryOutputStream final X-Git-Tag: v8.0.1~7 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=2209dcefbf9cf3b980ea0c0efab1ca29aed6cccc Make MemoryOutputStream final This is a checkstyle violation with upgraded checkstyle. Fix that. Change-Id: I370b50baa146a710632e501f1ce7acad913166c2 Signed-off-by: Robert Varga --- diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java index 029464a82b..b00e4bee4e 100644 --- a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java +++ b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/io/FileBackedOutputStream.java @@ -91,7 +91,7 @@ public class FileBackedOutputStream extends OutputStream { if (file != null) { return Files.newInputStream(file.toPath()); } else { - return new ByteArrayInputStream(memory.getBuffer(), 0, memory.getCount()); + return new ByteArrayInputStream(memory.buf(), 0, memory.count()); } } } @@ -178,20 +178,20 @@ public class FileBackedOutputStream extends OutputStream { throw new IOException("Stream already closed"); } - if (file == null && memory.getCount() + len > fileThreshold) { + if (file == null && memory.count() + len > fileThreshold) { final File temp = File.createTempFile("FileBackedOutputStream", null, fileDirectory == null ? null : new File(fileDirectory)); temp.deleteOnExit(); final Cleaner.Cleanable cleanup = FILE_CLEANER.register(this, () -> deleteFile(temp)); - LOG.debug("Byte count {} has exceeded threshold {} - switching to file: {}", memory.getCount() + len, + LOG.debug("Byte count {} has exceeded threshold {} - switching to file: {}", memory.count() + len, fileThreshold, temp); final OutputStream transfer; try { transfer = Files.newOutputStream(temp.toPath()); try { - transfer.write(memory.getBuffer(), 0, memory.getCount()); + transfer.write(memory.buf(), 0, memory.count()); transfer.flush(); } catch (IOException e) { try { @@ -224,12 +224,12 @@ public class FileBackedOutputStream extends OutputStream { /** * ByteArrayOutputStream that exposes its internals for efficiency. */ - private static class MemoryOutputStream extends ByteArrayOutputStream { - byte[] getBuffer() { + private static final class MemoryOutputStream extends ByteArrayOutputStream { + byte[] buf() { return buf; } - int getCount() { + int count() { return count; } }