HDFS-16092. Avoid creating LayoutFlags redundant objects (#3150)
(cherry picked from commit 93a1685073
)
This commit is contained in:
parent
47b3939009
commit
8538881710
@ -36,14 +36,15 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
public class LayoutFlags {
|
public class LayoutFlags {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a LayoutFlags object from a stream.
|
* Read next int from given input stream. If the value is not 0 (unsupported
|
||||||
|
* feature flags), throw appropriate IOException.
|
||||||
*
|
*
|
||||||
* @param in The stream to read from.
|
* @param in The stream to read from.
|
||||||
* @throws IOException
|
* @throws IOException If next byte read from given stream is not 0.
|
||||||
*/
|
*/
|
||||||
public static LayoutFlags read(DataInputStream in)
|
public static void read(DataInputStream in) throws IOException {
|
||||||
throws IOException {
|
|
||||||
int length = in.readInt();
|
int length = in.readInt();
|
||||||
if (length < 0) {
|
if (length < 0) {
|
||||||
throw new IOException("The length of the feature flag section " +
|
throw new IOException("The length of the feature flag section " +
|
||||||
@ -52,7 +53,6 @@ public static LayoutFlags read(DataInputStream in)
|
|||||||
throw new IOException("Found feature flags which we can't handle. " +
|
throw new IOException("Found feature flags which we can't handle. " +
|
||||||
"Please upgrade your software.");
|
"Please upgrade your software.");
|
||||||
}
|
}
|
||||||
return new LayoutFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LayoutFlags() {
|
private LayoutFlags() {
|
||||||
|
Loading…
Reference in New Issue
Block a user