[ 
https://issues.apache.org/jira/browse/FLINK-39873?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated FLINK-39873:
-----------------------------------
    Labels: pull-request-available  (was: )

> Add null check for connectedSocket in SocketStreamIterator.notifyOfError()
> --------------------------------------------------------------------------
>
>                 Key: FLINK-39873
>                 URL: https://issues.apache.org/jira/browse/FLINK-39873
>             Project: Flink
>          Issue Type: Bug
>            Reporter: Jubin Soni
>            Priority: Minor
>              Labels: pull-request-available
>
> The `notifyOfError()` method in `SocketStreamIterator` attempts to close 
> `connectedSocket` 
> without checking if it's null first, which can cause a `NullPointerException`.
> *Problem:*
> In `SocketStreamIterator.notifyOfError()` (line 212), the code calls:
> try {
>     connectedSocket.close();
> } catch (Throwable ignored) {
> }
> However, connectedSocket is only initialized during the first call to 
> readNextFromStream(). If notifyOfError() is called before any data is read 
> (e.g., during early initialization errors), connectedSocket will be null, 
> causing a NullPointerException. While the exception is caught and ignored, 
> this is poor practice and creates unnecessary exceptions. Other methods in 
> the same class (e.g., line 182) properly check for null before closing the 
> socket.
> *Proposed Solution:*
> Add a null check before attempting to close connectedSocket:if 
> (connectedSocket != null) {
>     try {
>         connectedSocket.close();
>     } catch (Throwable ignored) {
>     }
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to