]> source.dussan.org Git - jgit.git/commitdiff
[errorprone] Suppress ByteBufferBackingArray 81/204581/9
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 20 Sep 2023 13:03:53 +0000 (15:03 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Mon, 25 Sep 2023 20:06:12 +0000 (22:06 +0200)
The byte buffers used here are created by wrapping a byte[].

See https://errorprone.info/bugpattern/ByteBufferBackingArray

Change-Id: Idbc16d5ae4ff9f64b97be07a3cdf190716da191f

org.eclipse.jgit.ssh.apache/src/org/eclipse/jgit/internal/transport/sshd/auth/BasicAuthentication.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/dfs/DfsPackFile.java
org.eclipse.jgit/src/org/eclipse/jgit/patch/PatchApplier.java

index e5f884e2993b62d6ebd249d45d7c8cb1679234fe..8866976c89366e1a958842a2a455a98c71791efd 100644 (file)
@@ -63,6 +63,7 @@ public abstract class BasicAuthentication<ParameterType, TokenType>
                this.password = convert(initialPassword);
        }
 
+       @SuppressWarnings("ByteBufferBackingArray")
        private byte[] convert(char[] pass) {
                if (pass == null) {
                        return new byte[0];
index cea50bad0225525dfa9bac8bd7452f9c227b439c..8a2f4d3541cde2adbcd03652c151147338ffa030 100644 (file)
@@ -460,6 +460,7 @@ public final class DfsPackFile extends BlockBasedFile {
                }
        }
 
+       @SuppressWarnings("ByteBufferBackingArray")
        private long copyPackBypassCache(PackOutputStream out, ReadableChannel rc)
                        throws IOException {
                ByteBuffer buf = newCopyBuffer(out, rc);
index c18c83304c0787f37ba5d682999ff590baeac2c1..02c066cb24e74ed9e2d1810935983e0782630b4f 100644 (file)
@@ -863,6 +863,7 @@ public class PatchApplier {
                }
        }
 
+       @SuppressWarnings("ByteBufferBackingArray")
        private @Nullable ContentStreamLoader applyText(RawText rt, FileHeader fh, Result result)
                        throws IOException {
                List<ByteBuffer> oldLines = new ArrayList<>(rt.size());
@@ -1023,6 +1024,7 @@ public class PatchApplier {
                }
        }
 
+       @SuppressWarnings("ByteBufferBackingArray")
        private boolean canApplyAt(List<ByteBuffer> hunkLines,
                        List<ByteBuffer> newLines, int line) {
                int sz = hunkLines.size();
@@ -1054,11 +1056,13 @@ public class PatchApplier {
                return true;
        }
 
+       @SuppressWarnings("ByteBufferBackingArray")
        private ByteBuffer slice(ByteBuffer b, int off) {
                int newOffset = b.position() + off;
                return ByteBuffer.wrap(b.array(), newOffset, b.limit() - newOffset);
        }
 
+       @SuppressWarnings("ByteBufferBackingArray")
        private boolean isNoNewlineAtEnd(ByteBuffer hunkLine) {
                return Arrays.equals(NO_EOL, 0, NO_EOL.length, hunkLine.array(),
                                hunkLine.position(), hunkLine.limit());