Skip to content

Commit ff66e69

Browse files
committed
core: Opaque: Remove position offset from ByteBuffer constructor
Removing the relative offset (which in our case is always 0) will reduce the chance that somebody thinks it's an absolute offset from the beginning of the ByteBuffer... Related: #149 Signed-off-by: Christian Kohlschütter <[email protected]>
1 parent 7a64663 commit ff66e69

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

core/src/main/java/org/dcache/nfs/util/Opaque.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ public static Opaque forBytes(byte[] bytes) {
3939
}
4040

4141
/**
42-
* Returns an {@link Opaque} instance based on a copy of the {@code length} bytes from the given {@link ByteBuffer}
43-
* starting from the current {@link ByteBuffer#position()} plus the given {@code offset}.
42+
* Returns an {@link Opaque} instance based on a copy of the {@code length} bytes from the given {@link ByteBuffer}.
4443
*
4544
* @param buf The buffer.
46-
* @param offset The offset (relative to the current position).
4745
* @param length The number of bytes.
4846
* @return The {@link Opaque} instance.
4947
*/
50-
public static Opaque forBytes(ByteBuffer buf, int offset, int length) {
48+
public static Opaque forBytes(ByteBuffer buf, int length) {
5149
byte[] bytes = new byte[length];
52-
buf.get(bytes, offset, length);
50+
buf.get(bytes);
5351

5452
return new OpaqueImpl(bytes);
5553
}

core/src/main/java/org/dcache/nfs/vfs/Inode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public Inode(byte[] bytes) {
109109
exportIdx = b.getInt();
110110
type = (int) b.get();
111111
int olen = (int) b.get();
112-
this.opaqueKey = Opaque.forBytes(b, 0, olen);
112+
this.opaqueKey = Opaque.forBytes(b, olen);
113113

114114
this.nfsHandle = bytes.clone();
115115
}

0 commit comments

Comments
 (0)