mirror of
https://github.com/openjdk/jdk18u.git
synced 2025-12-10 15:20:36 -06:00
8272594: Better record of recordings
Reviewed-by: mgronlun
This commit is contained in:
parent
41fe8d2200
commit
eb2f497cf0
@ -66,6 +66,7 @@ final class MetadataReader {
|
||||
public MetadataReader(RecordingInput input) throws IOException {
|
||||
this.input = input;
|
||||
int size = input.readInt();
|
||||
input.require(size, "Metadata string pool size %d exceeds available data" );
|
||||
this.pool = new ArrayList<>(size);
|
||||
StringParser p = new StringParser(null, false);
|
||||
for (int i = 0; i < size; i++) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, 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
|
||||
@ -296,6 +296,7 @@ final class ParserFactory {
|
||||
@Override
|
||||
public Object parse(RecordingInput input) throws IOException {
|
||||
final int size = input.readInt();
|
||||
input.require(size, "Array size %d exceeds available data" );
|
||||
final Object[] array = new Object[size];
|
||||
for (int i = 0; i < size; i++) {
|
||||
array[i] = elementParser.parse(input);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2021, 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
|
||||
@ -418,6 +418,15 @@ public final class RecordingInput implements DataInput, AutoCloseable {
|
||||
return filename;
|
||||
}
|
||||
|
||||
// Purpose of this method is to prevent OOM by sanity check
|
||||
// the minimum required number of bytes against what is available in
|
||||
// segment/chunk/file
|
||||
public void require(int minimumBytes, String errorMessage) throws IOException {
|
||||
if (position + minimumBytes > size) {
|
||||
throw new IOException(String.format(errorMessage, minimumBytes));
|
||||
}
|
||||
}
|
||||
|
||||
// Purpose of this method is to reuse block cache from a
|
||||
// previous RecordingInput
|
||||
public void setFile(Path path) throws IOException {
|
||||
|
||||
@ -70,6 +70,7 @@ public final class StringParser extends Parser {
|
||||
@Override
|
||||
public Object parse(RecordingInput input) throws IOException {
|
||||
int size = input.readInt();
|
||||
input.require(size, "String size %d exceeds available data");
|
||||
ensureSize(size);
|
||||
if (lastSize == size) {
|
||||
boolean equalsLastString = true;
|
||||
@ -115,6 +116,7 @@ public final class StringParser extends Parser {
|
||||
@Override
|
||||
public Object parse(RecordingInput input) throws IOException {
|
||||
int size = input.readInt();
|
||||
input.require(size, "String size %d exceeds available data");
|
||||
ensureSize(size);
|
||||
if (lastSize == size) {
|
||||
boolean equalsLastString = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user