-
Notifications
You must be signed in to change notification settings - Fork 9
refactor: use StreamResourceWriter instead of InputStreamFactory #119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe recent changes involve updating various classes in the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
|
Sonar complains about a line that was already present in the codebase Line 71 in 9fafac3
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- pom.xml (1 hunks)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java (2 hunks)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java (2 hunks)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java (2 hunks)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java (3 hunks)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java (1 hunks)
- src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java (2 hunks)
Additional comments not posted (20)
src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java (2)
39-41: Class and logger setup looks good. The logger is correctly configured to use the class name.
43-43: Constructor correctly passes parameters to the superclass. Good use of inheritance.src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java (2)
43-45: Class and logger setup looks good. The logger is correctly configured to use the class name.
47-47: Constructor correctly initializes the superclass. Good use of inheritance.src/main/java/com/flowingcode/vaadin/addons/gridexporter/BaseStreamResourceWriter.java (2)
47-49: Class and logger setup looks good. The logger is correctly configured to use the class name.
54-59: Constructors are well-implemented, providing flexibility in template handling. Good use of default parameters.src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java (2)
58-60: Class and logger setup looks good. The logger is correctly configured to use the class name.
64-64: Constructor correctly passes parameters to the superclass. Good use of inheritance.pom.xml (1)
116-121: The addition ofjakarta.servlet-apiwith scopeprovidedis appropriate for servlet API usage without including it in the final artifact. Ensure this aligns with project requirements.src/main/java/com/flowingcode/vaadin/addons/gridexporter/ExcelStreamResourceWriter.java (7)
67-67: Class definition updated to extendBaseStreamResourceWriter.This change aligns with the PR's objective to transition from
InputStreamFactorytoStreamResourceWriter.
74-74: Constructor correctly initializes the superclass with parameters.The constructor's implementation is consistent with the expected behavior of initializing the base class with specific parameters for Excel export functionality.
79-85: Methodacceptcorrectly handles the Excel workbook creation and output stream writing.The method encapsulates the workbook creation and writing logic within a try-catch block, ensuring that any
IOExceptionis appropriately logged and handled.
Line range hint
87-153: MethodcreateWorkbookhas been refactored to include session locking and unlocking.The session management ensures thread safety during the workbook creation. This is a critical addition given the web context of Vaadin applications.
106-107: Use of merged regions to handle titles in the Excel sheet.This implementation allows dynamic merging based on the number of headers, which is a flexible approach to handling varying content widths.
136-139: Dynamic column sizing based on content.Automatically resizing columns based on their content improves the readability of the exported Excel file, which enhances user experience.
142-149: Handling of additional placeholders for custom cell values.This feature provides flexibility in managing additional data points in the Excel export, which can be particularly useful for reports that require custom formatted data.
src/main/java/com/flowingcode/vaadin/addons/gridexporter/GridExporter.java (4)
279-279: Ensure thePdfStreamResourceWriterconstructor matches the expected parameters.Verification successful
The constructor of
PdfStreamResourceWritermatches the expected parameters (GridExporter<T> exporter, String template).
PdfStreamResourceWriterconstructor:public PdfStreamResourceWriter(GridExporter<T> exporter, String template)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the constructor of `PdfStreamResourceWriter` accepts the correct parameters. # Test: Search for the constructor definition. Expect: Constructor with parameters matching those in the call. ast-grep --lang java --pattern $'class PdfStreamResourceWriter { PdfStreamResourceWriter(GridExporter $_, String $_) { $$$ } }'Length of output: 136
Script:
#!/bin/bash # Locate the file containing the PdfStreamResourceWriter class fd -e java 'PdfStreamResourceWriter' --exec cat {} + # Verify the constructor parameters within the located file ast-grep --lang java --pattern $'class PdfStreamResourceWriter { PdfStreamResourceWriter(GridExporter $_, String $_) { $$$ } }' $(fd -e java 'PdfStreamResourceWriter')Length of output: 2555
291-291: Ensure theExcelStreamResourceWriterconstructor matches the expected parameters.Verification successful
The constructor for
ExcelStreamResourceWritermatches the expected parameters.
ExcelStreamResourceWriter(GridExporter<T> exporter, String template)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the constructor of `ExcelStreamResourceWriter` accepts the correct parameters. # Test: Search for the constructor definition. Expect: Constructor with parameters matching those in the call. ast-grep --lang java --pattern $'class ExcelStreamResourceWriter { ExcelStreamResourceWriter(GridExporter $_, String $_) { $$$ } }'Length of output: 140
Script:
#!/bin/bash # Description: Search for the `ExcelStreamResourceWriter` class definition and its constructor. # Step 1: Search for the `ExcelStreamResourceWriter` class definition. ast-grep --lang java --pattern 'class ExcelStreamResourceWriter { $$$ }' # Step 2: Search for the constructor within the `ExcelStreamResourceWriter` class. ast-grep --lang java --pattern 'class ExcelStreamResourceWriter { ExcelStreamResourceWriter($$$) { $$$ } }'Length of output: 192
Script:
#!/bin/bash # Description: Search for the `ExcelStreamResourceWriter` class definition and its constructor using broader search patterns. # Step 1: Search for the `ExcelStreamResourceWriter` class definition. rg 'class ExcelStreamResourceWriter' -t java # Step 2: Search for the constructor within the `ExcelStreamResourceWriter` class. rg 'ExcelStreamResourceWriter\(.*\)' -t javaLength of output: 422
283-283: Ensure theCsvStreamResourceWriterconstructor matches the expected parameters.Verification successful
The constructor of
CsvStreamResourceWriteraccepts aGridExporterparameter, which matches the expected parameter in the code snippet provided.
CsvStreamResourceWriterconstructor:public CsvStreamResourceWriter(GridExporter<T> exporter)This confirms that the constructor call in the code snippet is correct.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the constructor of `CsvStreamResourceWriter` accepts the correct parameters. # Test: Search for the constructor definition. Expect: Constructor with parameters matching those in the call. ast-grep --lang java --pattern $'class CsvStreamResourceWriter { CsvStreamResourceWriter(GridExporter $_) { $$$ } }'Length of output: 125
Script:
#!/bin/bash # Locate the CsvStreamResourceWriter class definition fd -e java -x grep -Hn 'class CsvStreamResourceWriter' {} + # Verify the constructor parameters of the CsvStreamResourceWriter class ast-grep --lang java --pattern 'class CsvStreamResourceWriter { CsvStreamResourceWriter($_) { $$$ } }'Length of output: 1283
Script:
#!/bin/bash # Display the contents of the CsvStreamResourceWriter class file to inspect its constructor cat src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.javaLength of output: 3755
271-271: Ensure theDocxStreamResourceWriterconstructor matches the expected parameters.Verification successful
The constructor for
DocxStreamResourceWritermatches the expected parameters (GridExporter<T> exporter, String template).
src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java: public DocxStreamResourceWriter(GridExporter<T> exporter, String template)Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the constructor of `DocxStreamResourceWriter` accepts the correct parameters. # Test: Search for the constructor definition. Expect: Constructor with parameters matching those in the call. ast-grep --lang java --pattern $'class DocxStreamResourceWriter { DocxStreamResourceWriter(GridExporter $_, String $_) { $$$ } }'Length of output: 138
Script:
#!/bin/bash # Description: Verify the existence of the `DocxStreamResourceWriter` class and its constructor. # Step 1: Search for the `DocxStreamResourceWriter` class definition. ast-grep --lang java --pattern 'class DocxStreamResourceWriter { $$$ }' # Step 2: If the class exists, search for its constructor with the expected parameters. ast-grep --lang java --pattern $'class DocxStreamResourceWriter { DocxStreamResourceWriter(GridExporter $_, String $_) { $$$ } }'Length of output: 212
Script:
#!/bin/bash # Description: Verify the existence of the `DocxStreamResourceWriter` class and inspect its constructors. # Step 1: Search for the `DocxStreamResourceWriter` class definition in the entire codebase. rg 'class DocxStreamResourceWriter' -t java # Step 2: If the class exists, search for all constructors of the `DocxStreamResourceWriter` class. rg 'DocxStreamResourceWriter(' -t javaLength of output: 346
Script:
#!/bin/bash # Description: Inspect constructors of the `DocxStreamResourceWriter` class. # Search for all constructors of the `DocxStreamResourceWriter` class. rg 'DocxStreamResourceWriter\(' -t javaLength of output: 207
src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/gridexporter/PdfStreamResourceWriter.java
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/gridexporter/CsvStreamResourceWriter.java
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java
Show resolved
Hide resolved
src/main/java/com/flowingcode/vaadin/addons/gridexporter/DocxStreamResourceWriter.java
Show resolved
Hide resolved
Ears twitch, hops abound, 🐇😕 |
paodb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for me it looks ok


Use StreamResourceWriter instead of InputStreamFactory + Thread + PipedInput/OutputStream + implicit StreamResource pipe.
Summary by CodeRabbit
New Features
Refactor