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

Set response status based on server handling logic status. #6381

Merged
merged 1 commit into from Sep 4, 2019

Conversation

denis-anisimov
Copy link
Contributor

@denis-anisimov denis-anisimov commented Sep 3, 2019

Fixes vaadin/vaadin-upload-flow#145


This change is Reviewable

@project-bot project-bot bot added this to External Reviews in OLD Vaadin Flow ongoing work (Vaadin 10+) Sep 3, 2019
Copy link
Contributor

@joheriks joheriks left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @denis-anisimov)


flow-server/src/main/java/com/vaadin/flow/server/communication/StreamReceiverHandler.java, line 95 at r1 (raw file):

    enum UploadStatus {
        OK, ERROR
    }

Not sure about the purpose of this enum. It is only used in the return type of streamToReceiver. Seems it could be simpler and cleaner to use Boolean throughout for the upload status.

Copy link
Contributor Author

@denis-anisimov denis-anisimov left a comment

Choose a reason for hiding this comment

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

Reviewable status: 1 unresolved discussion, 0 of 1 LGTMs obtained (waiting on @joheriks)


flow-server/src/main/java/com/vaadin/flow/server/communication/StreamReceiverHandler.java, line 95 at r1 (raw file):

Previously, joheriks (Johannes Eriksson) wrote…

Not sure about the purpose of this enum. It is only used in the return type of streamToReceiver. Seems it could be simpler and cleaner to use Boolean throughout for the upload status.

Simpler: yes.
Cleaner: not really in this specific situation.

I'm trying to avoid potential mistakes.
Yes, in fact this is just boolean.
But using boolean in this case means that the return type of the method will be Pair<Boolean,Boolean>.
And the first boolean is almost semantically the same the second boolean .
The method names don't help you to see semantical difference.
It's too easy to make a mistake and use another boolean value instead of the required one.
In fact you don't even know which value to use without go through all parts of the code.

So having Pair<Boolean,Boolean> is worse than having a method operation(boolean one, boolean two) where you also don't know which semantic is for the first arg and which is for the second. But in this case you may at least give more proper names for the args and add javadocs (in fact it's better to avoid such methods at all).

I'm trying to solve this semantic issue via typesafe way.
You don't have a chance to make a mistake with the current approach.

OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from External Reviews to Reviewer approved Sep 4, 2019
Copy link
Contributor

@joheriks joheriks left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! all discussions resolved, 1 of 1 LGTMs obtained


flow-server/src/main/java/com/vaadin/flow/server/communication/StreamReceiverHandler.java, line 95 at r1 (raw file):

Previously, denis-anisimov (Denis) wrote…

Simpler: yes.
Cleaner: not really in this specific situation.

I'm trying to avoid potential mistakes.
Yes, in fact this is just boolean.
But using boolean in this case means that the return type of the method will be Pair<Boolean,Boolean>.
And the first boolean is almost semantically the same the second boolean .
The method names don't help you to see semantical difference.
It's too easy to make a mistake and use another boolean value instead of the required one.
In fact you don't even know which value to use without go through all parts of the code.

So having Pair<Boolean,Boolean> is worse than having a method operation(boolean one, boolean two) where you also don't know which semantic is for the first arg and which is for the second. But in this case you may at least give more proper names for the args and add javadocs (in fact it's better to avoid such methods at all).

I'm trying to solve this semantic issue via typesafe way.
You don't have a chance to make a mistake with the current approach.

Ok, fair point (one could for consistency then consider using this enum as the return value of each of the methods that now return boolean, but that is not really important).

@denis-anisimov denis-anisimov merged commit 73ce1eb into master Sep 4, 2019
OLD Vaadin Flow ongoing work (Vaadin 10+) automation moved this from Reviewer approved to Done - pending release Sep 4, 2019
@denis-anisimov denis-anisimov deleted the 145-upload-stream-failure branch September 4, 2019 08:59
@denis-anisimov denis-anisimov added this to the 2.0.11 milestone Sep 9, 2019
@denis-anisimov denis-anisimov moved this from Done - pending release to Released in OLD Vaadin Flow ongoing work (Vaadin 10+) Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upload succeeds even if the receiver throws exception
2 participants