8304591: (fs) UnixPath.stringValue need not be volatile
Reviewed-by: alanb, bpb, shade
This commit is contained in:
parent
60640a216d
commit
395a4ce0dd
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -57,8 +57,8 @@ class UnixPath implements Path {
|
||||
// internal representation
|
||||
private final byte[] path;
|
||||
|
||||
// String representation (created lazily)
|
||||
private volatile String stringValue;
|
||||
// String representation (created lazily, no need to be volatile)
|
||||
private String stringValue;
|
||||
|
||||
// cached hashcode (created lazily, no need to be volatile)
|
||||
private int hash;
|
||||
@ -761,8 +761,9 @@ class UnixPath implements Path {
|
||||
@Override
|
||||
public String toString() {
|
||||
// OK if two or more threads create a String
|
||||
String stringValue = this.stringValue;
|
||||
if (stringValue == null) {
|
||||
stringValue = fs.normalizeJavaPath(Util.toString(path)); // platform encoding
|
||||
this.stringValue = stringValue = fs.normalizeJavaPath(Util.toString(path)); // platform encoding
|
||||
}
|
||||
return stringValue;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user