anchitbhatia / Distributed-messaging-system

dsd-pub-sub-project-anchitbhatia created by GitHub Classroom
1 stars 0 forks source link

Why connection exception for empty queue? #9

Open adelgadocabrera opened 2 years ago

adelgadocabrera commented 2 years ago

I don't understand why throw connection exception for empty list? Why not just return null? Perhaps I'm not seeing something.

https://github.com/CS682-S22/dsd-pub-sub-project-anchitbhatia/blob/1cdf79e83816160c8ea636020afb70f7988ad19b/src/main/java/api/Consumer.java#L46-L48

anchitbhatia commented 2 years ago

This is to differentiate whether the connection is closed or timeout occurred while polling (returns null). If i would have just returned null then the application would still keep on polling from the queue even when the connection is closed.

adelgadocabrera commented 2 years ago

Oh, I see I see. Thanks