Skip to content
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

Upload log improvements #707

Merged
merged 2 commits into from
Jan 20, 2021
Merged

Conversation

nolantellis
Copy link
Contributor

No description provided.

Copy link
Contributor

@raboczi raboczi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the walkthrough of the code and everything looks well-reasoned. My only quibble was that where streams are now buffered in temp files rather than in RAM, we should make an effort to clean them up lest the temp area leak.

@@ -277,10 +291,11 @@ private void uploadFileFromURL(String fileUrl) throws ExceptionImport, Exception
READ_TIMEOUT);
InputStream targetStream = new FileInputStream(testData);

media = new MediaImpl(testData.getName(), targetStream, Charset.forName("UTF-8"));
media = new MediaImpl(testData.getName(), targetStream, Charset.forName("UTF-8"),
Copy link
Contributor

@fsmicdev fsmicdev Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Minor] Though existing code, in all files you changed in this commit, suggest utilising StandardCharsets.UTF_8.toString() constant rather than string literal "UTF-8". If the string literal is utilised in multiple places within the one file, can create local class constant e.g. private static final String UTF8_CHARSET = StandardCharsets.UTF_8.toString(); and reference that in the multiple local places. String literals/any type literal (which is magic) anywhere should be discouraged moving forwards (it's a bad code smell from existing codebase).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Executions.getCurrent().sendRedirect("import-csv/csvimporter.zul", "_blank");
break;

case MODAL:
Copy link
Contributor

@fsmicdev fsmicdev Jan 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Suggestion & Minor] Is this an intentional fall-through to 'default' branch of switch statement? If so, and in any case, suggest adding a code comment under case MODAL mentioning this/reasoning on your switch MODAL with empty block conditional processing, as it aids in understanding the empty block which late at night may be counter-intuitive/hard to decipher if someone picks up this code, to refactor/understand. Or, just remove as it's a bit weird looking and in this case confusing (if you want to leave it there, please have a comment why you're leaving it in as mentioned first) Ref: https://rules.sonarsource.com/cpp/RSPEC-3458

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is legacy code, and Nolan asked the same question. I guess the intention was to create a view either in the same page or in a modal popup depends on case values. Probably it's safe to remove "case MODAL" to avoid confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Frank. Agree - less confusing code is good code - regardless if there is history behind it, someone picking up the code shouldn't need to know that history ( and, it is definately safe to remove case MODAL ).

Copy link
Contributor

@fsmicdev fsmicdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a quick look - good functional changes, added a couple of code improvement suggestions, for maintenance/quality. Well done @nolantellis

Executions.getCurrent().sendRedirect("import-csv/csvimporter.zul", "_blank");
break;

case MODAL:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part is legacy code, and Nolan asked the same question. I guess the intention was to create a view either in the same page or in a modal popup depends on case values. Probably it's safe to remove "case MODAL" to avoid confusion.

@nolantellis nolantellis merged commit ab4d581 into release/v7.19 Jan 20, 2021
@raboczi raboczi deleted the task/upload-file/AP-3003 branch April 29, 2022 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants