benedekh / WeLoveClouds

Repository for submissions on the CloudDB course.
0 stars 1 forks source link

[Concurrent]CommunicationService caches received byte[] until it recognies that is a valid *Message #111

Closed benedekh closed 7 years ago

benedekh commented 7 years ago

where * can be:

The problem with that is, if a malicious client floods the Socket from which the [Concurrent]CommunicationService reads the bytes, then it will cache as long as the underlying buffer (ByteArrayOutputStream) is capable of that.

Although if an Exception (either ClientNotConnected - in case of Communication Service, or IOException - in case of ConcurrentCommunicationService) is thrown, then the method which called the [Concurrent]CommunicationService.receive() will close the respective connection (along with the Socket stored inside). It is because that method thinks the connection was closed by the other side.

But I'm not sure if a ByteArrayOutputStream can ever be full...