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

Replace new DefaultStreamMessage() to StreamMessage.streaming() #4717

Merged
merged 6 commits into from
Mar 9, 2023

Conversation

injae-kim
Copy link
Contributor

Related PR #4696, Issue #4253

Motivation:

   static <T> StreamMessageWriter<T> streaming() {
      return new DefaultStreamMessage<>();

So you want to deprecate this class in the follow-up PR?
I mean deprecating the whole class because it doesn't need to be exposed to public.

Modifications:

  • Replace new DefaultStreamMessage() to StreamMessage.streaming()

Result:

  • Now we can hide new DefaultStreamMessage() more and use StreamMessage.streaming() instead

@injae-kim injae-kim force-pushed the remove-default-stream-message-usage branch 2 times, most recently from f93df5f to c40543e Compare March 2, 2023 16:24
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

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

Thanks for cleaning up!

@ikhoon ikhoon added the cleanup label Mar 3, 2023
@ikhoon ikhoon added this to the 1.23.0 milestone Mar 3, 2023
@injae-kim
Copy link
Contributor Author

injae-kim commented Mar 3, 2023

private static DefaultStreamMessage<StreamMessage<HttpData>> newEmitter(Subscription upstream) {
final DefaultStreamMessage<StreamMessage<HttpData>> emitter =
new DefaultStreamMessage<StreamMessage<HttpData>>() {
@Override
protected void onRequest(long n) {
// A BodyPart is converted to a StreamMessage<HttpData> one to one.
upstream.request(n);
}
};

FYI, I found that some classes extends or overrides DefaultStreamMessage directly on another module.
So If we make DefaultStreamMessage package-private, we can't overrides like above on MultipartEncoder.

image

Also, If we add @Deprecated annotation on DefaultStreamMessage, it's looks weird on my IDE. (using DefaultStreamMessage directly looks like above, deprecated)

So I just replace new DefaultStreamMessage() to StreamMessage.streaming() as much as possible in this PR~!

@trustin
Copy link
Member

trustin commented Mar 3, 2023

So I just replace new DefaultStreamMessage() to StreamMessage.streaming() as much as possible in this PR~!

Sounds good to me.

Copy link
Member

@trustin trustin left a comment

Choose a reason for hiding this comment

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

Thanks a lot, @injae-kim !

@minwoox
Copy link
Contributor

minwoox commented Mar 6, 2023

How about at least adding @Deprecated to the constructor so that people use the static method instead?

/**
 * Creates a new instance.
 * 
 * @deprecated Use ...
 */
@Deprecated
public DefaultStreamMessage() {...}

@injae-kim
Copy link
Contributor Author

image

image

If we add @Deprecated annotation on DefaultStreamMessage constructor, DefaultHttpResponse, DefaultHttpRequest also looks deprecated cause they extend DefaultStreamMessage..

@minwoox , is it okay? then I'll add @Deprecated and update this PR~!

@minwoox
Copy link
Contributor

minwoox commented Mar 6, 2023

@minwoox , is it okay? then I'll add @deprecated and update this PR~!

I think it's okay and we should so that users no more use the constructor of DefaultStreamMessage. If we don't, users will still use the constructor and it will bother users when we hit 2.0 and remove the constructor.

DefaultHttpResponse, DefaultHttpRequest

I realized that we also need to deprecate those APIs. Users should use HttpResponse.streaming() and HttpRequest.streaming(headers) instead. Could you also deprecate those?

@injae-kim injae-kim force-pushed the remove-default-stream-message-usage branch from 0717db4 to bffad77 Compare March 6, 2023 13:39
@injae-kim
Copy link
Contributor Author

injae-kim commented Mar 8, 2023

📌 I'll resolve the conflict soon Done.

@injae-kim injae-kim force-pushed the remove-default-stream-message-usage branch from bffad77 to ffff582 Compare March 8, 2023 10:26
@injae-kim injae-kim force-pushed the remove-default-stream-message-usage branch from ffff582 to a378fa7 Compare March 8, 2023 10:33
@@ -26,7 +26,7 @@
import com.linecorp.armeria.internal.common.stream.AbortingSubscriber;
import com.linecorp.armeria.internal.common.stream.StreamMessageUtil;

abstract class AbstractStreamMessageWriter<T> extends CancellableStreamMessage<T> implements StreamWriter<T> {
abstract class AbstractStreamWriter<T> extends CancellableStreamMessage<T> implements StreamWriter<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, it seems like the file name isn't changed. 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

abstract class AbstractStreamMessageWriter<T> extends CancellableStreamMessage<T> implements StreamWriter<T> {

oh on latest master branch, still AbstractStreamMessageWriter .

It's better to rename AbstractStreamMessageWriter -> AbstractStreamWriter?
(cause we rename StreamMessageWrtier -> StreamWriter)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

or.. I don't rename AbstractStreamMessageWriter in previous PR cause it implements CancellableStreamMessage + StreamWriter 😅

Comment on lines 50 to 51
// Delegate to coroutine's exception handling mechanism,
// which ignores CancellationException.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Delegate to coroutine's exception handling mechanism,
// which ignores CancellationException.

We don't delegate anymore so let's just remove this comment. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✅ updated!

Copy link
Contributor

@minwoox minwoox left a comment

Choose a reason for hiding this comment

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

Thanks a lot, @injae-kim for cleaning this up!

Copy link
Contributor

@jrhee17 jrhee17 left a comment

Choose a reason for hiding this comment

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

Thanks @injae-kim ! 🙇 👍 🙇

Comment on lines 35 to 37
* @deprecated Use {@link HttpRequest#streaming(RequestHeaders)} instead.
*/
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

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

It is in internal. Do we need @Deprecated?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, no we don't need it. Let me revert it. 😓

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for catching 🙇

@ikhoon ikhoon merged commit 179d9a5 into line:master Mar 9, 2023
@ikhoon
Copy link
Contributor

ikhoon commented Mar 9, 2023

Thanks for cleaning up! 🚀🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants