@@ -97,32 +97,32 @@ private boolean is(int flags) {
97
97
private final RecordingInput input ;
98
98
private final ChunkHeader chunkHeader ;
99
99
private final TimeConverter timeConverter ;
100
-
100
+ private final ParserState parserState ;
101
101
private final LongMap <ConstantLookup > constantLookups ;
102
102
103
103
private LongMap <Type > typeMap ;
104
104
private LongMap <Parser > parsers ;
105
105
private boolean chunkFinished ;
106
106
107
107
private ParserConfiguration configuration ;
108
- private volatile boolean closed ;
109
108
private MetadataDescriptor previousMetadata ;
110
109
private MetadataDescriptor metadata ;
111
110
private boolean staleMetadata = true ;
112
111
113
- public ChunkParser (RecordingInput input ) throws IOException {
114
- this (input , new ParserConfiguration ());
112
+ public ChunkParser (RecordingInput input , ParserState ps ) throws IOException {
113
+ this (input , new ParserConfiguration (), ps );
115
114
}
116
115
117
- ChunkParser (RecordingInput input , ParserConfiguration pc ) throws IOException {
118
- this (new ChunkHeader (input ), null , pc );
116
+ ChunkParser (RecordingInput input , ParserConfiguration pc , ParserState ps ) throws IOException {
117
+ this (new ChunkHeader (input ), null , pc , ps );
119
118
}
120
119
121
- private ChunkParser (ChunkParser previous ) throws IOException {
122
- this (new ChunkHeader (previous .input ), previous , new ParserConfiguration ());
120
+ private ChunkParser (ChunkParser previous , ParserState ps ) throws IOException {
121
+ this (new ChunkHeader (previous .input ), previous , new ParserConfiguration (), ps );
123
122
}
124
123
125
- private ChunkParser (ChunkHeader header , ChunkParser previous , ParserConfiguration pc ) throws IOException {
124
+ private ChunkParser (ChunkHeader header , ChunkParser previous , ParserConfiguration pc , ParserState ps ) throws IOException {
125
+ this .parserState = ps ;
126
126
this .configuration = pc ;
127
127
this .input = header .getInput ();
128
128
this .chunkHeader = header ;
@@ -155,7 +155,7 @@ private ChunkParser(ChunkHeader header, ChunkParser previous, ParserConfiguratio
155
155
}
156
156
157
157
public ChunkParser nextChunkParser () throws IOException {
158
- return new ChunkParser (chunkHeader .nextHeader (), this , configuration );
158
+ return new ChunkParser (chunkHeader .nextHeader (), this , configuration , parserState );
159
159
}
160
160
161
161
private void updateConfiguration () {
@@ -280,7 +280,7 @@ private boolean awaitUpdatedHeader(long absoluteChunkEnd, long filterEnd) throws
280
280
Logger .log (LogTag .JFR_SYSTEM_PARSER , LogLevel .INFO , "Waiting for more data (streaming). Read so far: " + chunkHeader .getChunkSize () + " bytes" );
281
281
}
282
282
while (true ) {
283
- if (closed ) {
283
+ if (parserState . isClosed () ) {
284
284
return true ;
285
285
}
286
286
if (chunkHeader .getLastNanos () > filterEnd ) {
@@ -437,7 +437,7 @@ public boolean isLastChunk() throws IOException {
437
437
}
438
438
439
439
ChunkParser newChunkParser () throws IOException {
440
- return new ChunkParser (this );
440
+ return new ChunkParser (this , parserState );
441
441
}
442
442
443
443
public boolean isChunkFinished () {
@@ -457,7 +457,7 @@ public boolean isFinalChunk() {
457
457
}
458
458
459
459
public void close () {
460
- this . closed = true ;
460
+ parserState . close () ;
461
461
try {
462
462
input .close ();
463
463
} catch (IOException e ) {
0 commit comments