Skip to content

Commit 72b87c9

Browse files
committed
core: NFS4Client: Use Opaque.forBytes
Previously, we were using "new Opaque(bytes[])", which creates a new Opaque instance backed by the given byte[]. Since the Opaque key may be used in a "owners" hashmap, make sure that this information cannot be modified by the caller. Use the immutable "Opaque.forBytes" instead. Related: #149 Signed-off-by: Christian Kohlschütter <[email protected]>
1 parent f22dba3 commit 72b87c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/java/org/dcache/nfs/v4/NFS4Client.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public boolean isCallbackNeede() {
628628
public synchronized StateOwner getOrCreateOwner(byte[] owner, seqid4 seq) throws BadSeqidException {
629629
StateOwner stateOwner;
630630
if (_minorVersion == 0) {
631-
Opaque k = new Opaque(owner);
631+
Opaque k = Opaque.forBytes(owner);
632632
stateOwner = _owners.get(k);
633633
if (stateOwner == null) {
634634
state_owner4 so = new state_owner4();
@@ -655,7 +655,7 @@ public synchronized StateOwner getOrCreateOwner(byte[] owner, seqid4 seq) throws
655655
* @param owner client unique state owner
656656
*/
657657
public synchronized void releaseOwner(byte[] owner) throws StaleClientidException {
658-
Opaque k = new Opaque(owner);
658+
Opaque k = Opaque.forBytes(owner);
659659
StateOwner stateOwner = _owners.remove(k);
660660
if (stateOwner == null) {
661661
throw new StaleClientidException();

0 commit comments

Comments
 (0)