File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
spring-ai-core/src/main/java/org/springframework/ai/reader Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -45,11 +45,11 @@ public class TextReader implements DocumentReader {
4545 private final Resource resource ;
4646
4747 /**
48- * @return Character set to be used when loading data from the
48+ * Character set to be used when loading data from the
4949 */
5050 private Charset charset = StandardCharsets .UTF_8 ;
5151
52- private Map <String , Object > customMetadata = new HashMap <>();
52+ private final Map <String , Object > customMetadata = new HashMap <>();
5353
5454 public TextReader (String resourceUrl ) {
5555 this (new DefaultResourceLoader ().getResource (resourceUrl ));
@@ -85,7 +85,8 @@ public List<Document> get() {
8585
8686 // Inject source information as a metadata.
8787 this .customMetadata .put (CHARSET_METADATA , this .charset .name ());
88- this .customMetadata .put (SOURCE_METADATA , this .resource .getFilename ());
88+ this .customMetadata .put (SOURCE_METADATA , this .resource .getFilename () != null ? this .resource .getFilename ()
89+ : Objects .toIdentityString (this .resource ));
8990
9091 return List .of (new Document (document , this .customMetadata ));
9192
You can’t perform that action at this time.
0 commit comments