Github user mxm commented on the pull request:
https://github.com/apache/flink/pull/992#issuecomment-130588652
Thanks for your changes. I think we should use `read()` instead of
`readLine()` because we are using a custom delimiter and not necessarily "\n"
(newline symbol). The danger of reading an entire line is that the newline
symbol might never arrive. So it might continue to read forever. And even if it
manages to find a newline symbol, you have to truncate your input to find the
custom delimiter. That's not very efficient. Can you change the code back to
using the `read()` method? I think we had a misunderstanding.
For you test case: It's not considered good practice to mix production and
test code. You're doing that by introducing the `isRetrying` flag and exposing
it. Alternatively, you have two options:
1. Create a `ServerSocket` and pass its address to the
`SocketTextStreamFunction`. Then control the connection to this socket and
count how often the function reconnects (e.g. use the `accept()` method).
2. Create your test in the same package as the `SocketTextStreamFunction`
function (package is `org.apache.flink.streaming.api.functions.source`). Then
you can access all field variables which are protected. So make your `retries`
variable a protected field variable of the `SocketTextStreamFunction` class.
I hope that this helps you. If not, feel free to ask more questions.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---