[ 
https://issues.apache.org/jira/browse/FLINK-2490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14693104#comment-14693104
 ] 

ASF GitHub Bot commented on FLINK-2490:
---------------------------------------

Github user mxm commented on the pull request:

    https://github.com/apache/flink/pull/992#issuecomment-130213092
  
    @HuangWHWHW `read()` method of the `BufferedReader` object returns `-1` in 
case the end of the stream has been reached.
    
    A couple of things I noticed apart from the `retryForever` issue. I wonder 
if we can fix these with this pull request as well:
    
    1. The control flow of the `streamFromSocket` function is hard to predict 
because there are many `while` loops with `break`, `continue`, or `throw` 
statements.
    2. We could use `StringBuilder` instead of `StringBuffer` in this class. 
`StringBuilder` is faster in the case of single-threaded access.
    3. The function reads a single character at a time from the socket. It is 
more efficient to use a buffer and read several characters at once.
    
    @HuangWHWHW You asked how you could count the number of retries in a unit 
test. Typically, you would insert a `Mock` or a `Spy` into your test method. 
Unfortunately, this does not work here because the socket variables is 
overwritten in case of a retry. So for this test, I would recommend creating a 
local `ServerSocket` and let the function connect to this socket. You can then 
control the failures from your test socket. 


> Remove unwanted boolean check in function 
> SocketTextStreamFunction.streamFromSocket
> -----------------------------------------------------------------------------------
>
>                 Key: FLINK-2490
>                 URL: https://issues.apache.org/jira/browse/FLINK-2490
>             Project: Flink
>          Issue Type: Bug
>          Components: Streaming
>    Affects Versions: 0.10
>            Reporter: Huang Wei
>            Priority: Minor
>             Fix For: 0.10
>
>   Original Estimate: 168h
>  Remaining Estimate: 168h
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to