jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
663 stars 123 forks source link

"Search" add-on adds unnecessary stacktrace to log if an unsupported file format is provided #3660

Closed fractal3000 closed 1 month ago

fractal3000 commented 2 months ago

Environment

Jmix version: 2.3.3

Bug Description

Search add-on processes not-document file types in not a correct way.

Steps To Reproduce

Create project with search add-on. Create entity with field of "FileReference" type. Create search index definition with pointing of the attribute. Start project Login to UI Add enitities data with adding files of some not-document format (e.g. sql) See the console log

Current Behavior

Long stack trace is appeared.

Expected Behavior

There is human readable message about using not supporting file format.

The stack trace is:

io.jmix.search.exception.FileParseException: Unable to parse file 'dmt_ndfl6_division.sql': Parser not found   at io.jmix.search.utils.FileProcessor.lambda$getParser$0(FileProcessor.java:85) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at java.base/java.util.Optional.orElseThrow(Optional.java:403) ~[na:na]   at io.jmix.search.utils.FileProcessor.getParser(FileProcessor.java:85) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.utils.FileProcessor.extractFileContent(FileProcessor.java:58) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.mapping.propertyvalue.impl.FilePropertyValueExtractor.addFileContent(FilePropertyValueExtractor.java:91) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.mapping.propertyvalue.impl.FilePropertyValueExtractor.processFileRef(FilePropertyValueExtractor.java:80) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.mapping.propertyvalue.impl.FilePropertyValueExtractor.transformSingleValue(FilePropertyValueExtractor.java:63) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.mapping.propertyvalue.impl.AbstractPropertyValueExtractor.processValue(AbstractPropertyValueExtractor.java:89) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.mapping.propertyvalue.impl.AbstractPropertyValueExtractor.getValue(AbstractPropertyValueExtractor.java:46) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.mapping.MappingFieldDescriptor.getValue(MappingFieldDescriptor.java:146) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.impl.BaseEntityIndexer.addFieldValueToEntityIndexContent(BaseEntityIndexer.java:302) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.impl.BaseEntityIndexer.lambda$generateIndexDocument$11(BaseEntityIndexer.java:289) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]   at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[na:na]   at java.base/java.util.HashMap$ValueSpliterator.forEachRemaining(HashMap.java:1779) ~[na:na]   at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]   at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]   at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]   at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]   at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]   at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]   at io.jmix.search.index.impl.BaseEntityIndexer.generateIndexDocument(BaseEntityIndexer.java:289) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.impl.BaseEntityIndexer.indexGroupedInstances(BaseEntityIndexer.java:142) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.impl.BaseEntityIndexer.indexCollectionByEntityIds(BaseEntityIndexer.java:97) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.queue.impl.JpaIndexingQueueManager.processQueueItemsGroup(JpaIndexingQueueManager.java:513) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.queue.impl.JpaIndexingQueueManager.processQueueItems(JpaIndexingQueueManager.java:498) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.queue.impl.JpaIndexingQueueManager.processQueue(JpaIndexingQueueManager.java:458) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.queue.impl.JpaIndexingQueueManager.processNextBatch(JpaIndexingQueueManager.java:301) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.search.index.queue.impl.JpaIndexingQueueManager.processNextBatch(JpaIndexingQueueManager.java:296) ~[jmix-search-2.4.999-SNAPSHOT.jar:na]   at io.jmix.autoconfigure.search.job.IndexingQueueProcessingJob.execute(IndexingQueueProcessingJob.java:32) ~[jmix-search-starter-2.4.999-SNAPSHOT.jar:na]   at org.quartz.core.JobRunShell.run(JobRunShell.java:202) ~[quartz-2.3.2.jar:na]   at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) ~[quartz-2.3.2.jar:na]

fractal3000 commented 2 months ago

This issue is linked with https://github.com/jmix-framework/jmix/issues/3659 And it should be fixed after the linked issue have been fixed.

SergeiAksenov2 commented 1 month ago

Tested on: Jmix version: 2.4.999-SNAPSHOT Jmix Studio plugin version: 2.3.SNAPSHOT6810-242 IntelliJ version: IntelliJ IDEA 2024.2.1 (Community Edition)

No exception, but there is the hardcoded message in logs: The file the-file-with-not-supported-extension.sql with 'sql' extension is not supported. Only following formats are supported: pdf, doc, docx, xls, xlsx, odt, ods, rtf, txt.

fractal3000 commented 1 month ago

The new issue for fixing this prblem in the "master" branch was created https://github.com/jmix-framework/jmix/issues/3690

SergeiAksenov2 commented 1 month ago

Tested on: Jmix version: 2.4.999-SNAPSHOT Jmix Studio plugin version: 2.4.SNAPSHOT6843-241 IntelliJ version: IntelliJ IDEA 2024.1.6 (Community Edition)