@@ -114,16 +114,33 @@ public ChecksumBlobStoreFormat(
114114
115115 /**
116116 * Reads and parses the blob with given name, applying name translation using the {link #blobName} method
117- *
118- * @param blobContainer blob container
119- * @param name name to be translated into
120- * @return parsed blob object
117+ * @param projectRepo the project repository context, used for deserialization
118+ * @param blobContainer the {@link BlobContainer} from which to read the blob
119+ * @param name the logical name of the blob to read (will be formatted to the actual blob name)
120+ * @param namedXContentRegistry the {@link NamedXContentRegistry} to use for parser construction
121+ * @return the deserialized object of type {@code T} read from the blob
122+ * @throws IOException if an I/O error occurs while reading or parsing the blob
121123 */
122124 public T read (ProjectRepo projectRepo , BlobContainer blobContainer , String name , NamedXContentRegistry namedXContentRegistry )
125+ throws IOException {
126+ return read (projectRepo , blobContainer , name , namedXContentRegistry , null );
127+ }
128+
129+ /**
130+ * Reads and parses the blob with given name, applying name translation using the {link #blobName} method
131+ * @param projectRepo the project repository context, used for deserialization
132+ * @param blobContainer the {@link BlobContainer} from which to read the blob
133+ * @param name the logical name of the blob to read (will be formatted to the actual blob name)
134+ * @param namedXContentRegistry the {@link NamedXContentRegistry} to use for parser construction
135+ * @param xContentParserConfiguration An optional {@link XContentParserConfiguration} to use when deserializing the blob
136+ * @return the deserialized object of type {@code T} read from the blob
137+ * @throws IOException if an I/O error occurs while reading or parsing the blob
138+ */
139+ public T read (ProjectRepo projectRepo , BlobContainer blobContainer , String name , NamedXContentRegistry namedXContentRegistry , XContentParserConfiguration xContentParserConfiguration )
123140 throws IOException {
124141 String blobName = blobName (name );
125142 try (InputStream in = blobContainer .readBlob (OperationPurpose .SNAPSHOT_METADATA , blobName )) {
126- return deserialize (projectRepo , namedXContentRegistry , in );
143+ return deserialize (projectRepo , namedXContentRegistry , in , xContentParserConfiguration );
127144 }
128145 }
129146
@@ -132,6 +149,10 @@ public String blobName(String name) {
132149 }
133150
134151 public T deserialize (ProjectRepo projectRepo , NamedXContentRegistry namedXContentRegistry , InputStream input ) throws IOException {
152+ return deserialize (projectRepo , namedXContentRegistry , input , null );
153+ }
154+
155+ public T deserialize (ProjectRepo projectRepo , NamedXContentRegistry namedXContentRegistry , InputStream input , XContentParserConfiguration xContentParserConfiguration ) throws IOException {
135156 final DeserializeMetaBlobInputStream deserializeMetaBlobInputStream = new DeserializeMetaBlobInputStream (input );
136157 try {
137158 CodecUtil .checkHeader (new InputStreamDataInput (deserializeMetaBlobInputStream ), codec , VERSION , VERSION );
@@ -149,8 +170,10 @@ public T deserialize(ProjectRepo projectRepo, NamedXContentRegistry namedXConten
149170 deserializeMetaBlobInputStream .verifyFooter ();
150171 try (
151172 XContentParser parser = XContentHelper .createParserNotCompressed (
152- XContentParserConfiguration .EMPTY .withRegistry (namedXContentRegistry )
153- .withDeprecationHandler (LoggingDeprecationHandler .INSTANCE ),
173+ xContentParserConfiguration == null
174+ ? XContentParserConfiguration .EMPTY .withRegistry (namedXContentRegistry )
175+ .withDeprecationHandler (LoggingDeprecationHandler .INSTANCE )
176+ : xContentParserConfiguration ,
154177 bytesReference ,
155178 XContentType .SMILE
156179 )
@@ -160,8 +183,10 @@ public T deserialize(ProjectRepo projectRepo, NamedXContentRegistry namedXConten
160183 } catch (Exception e ) {
161184 try (
162185 XContentParser parser = XContentHelper .createParserNotCompressed (
163- XContentParserConfiguration .EMPTY .withRegistry (namedXContentRegistry )
164- .withDeprecationHandler (LoggingDeprecationHandler .INSTANCE ),
186+ xContentParserConfiguration == null
187+ ? XContentParserConfiguration .EMPTY .withRegistry (namedXContentRegistry )
188+ .withDeprecationHandler (LoggingDeprecationHandler .INSTANCE )
189+ : xContentParserConfiguration ,
165190 bytesReference ,
166191 XContentType .SMILE
167192 )
@@ -392,10 +417,10 @@ public void close() {
392417 // in order to write the footer we need to prevent closing the actual index input.
393418 }
394419 };
395- XContentBuilder builder = XContentFactory .contentBuilder (
396- XContentType .SMILE ,
397- compress ? CompressorFactory .COMPRESSOR .threadLocalOutputStream (indexOutputOutputStream ) : indexOutputOutputStream
398- )
420+ XContentBuilder builder = XContentFactory .contentBuilder (
421+ XContentType .SMILE ,
422+ compress ? CompressorFactory .COMPRESSOR .threadLocalOutputStream (indexOutputOutputStream ) : indexOutputOutputStream
423+ )
399424 ) {
400425 ToXContent .Params params = extraParams .isEmpty ()
401426 ? SNAPSHOT_ONLY_FORMAT_PARAMS
0 commit comments