Skip to content

[Bug] [connector-file-sftp] SFTPInputStream.close does not correctly trigger the closing of the file stream #6323

@panpan2019

Description

@panpan2019

Search before asking

  • I had searched in the issues and found no similar issues.

What happened

When closing SFTPInputStream after SFTP read/write completion, the SFTPInputStream.close method is not properly closing the file stream. This can lead to resource leaks.

SeaTunnel Version

2.3.2

SeaTunnel Config

env {
  execution.parallelism = 2
  job.mode = "BATCH"

}
source{
   SftpFile {
    path = "/home/dataos/test"
    host = "xxxx"
    port = 22
    user = xxx
    password = "****"
    file_format_type = "text"
    result_table_name = SftpFile_source_4
    schema = {
     fields {
      name = string
      age = int
      }
    }
    delimiter = ","
   }
  } 
  
 transform{
    Sql{
     source_table_name = "SftpFile_source_4"
    result_table_name = "Sql-transform-4"
    query = "select name,age, DES_ENCRYPT('1111111111',name)  des_name from SftpFile_source_4"
    }
  }
  
  sink {
    SftpFile{
      file_format_type="text",
      path = "/home/test1"
      host = "xxx"
      port = 22
      user = xxx
      password = "****"
      file_format_type = "text"
      field_delimiter=",",
      row_delimiter= "/t",
      sink_columns = ["name","age","des_name"]
      source_table_name="Sql-transform-4" 
    }
  }

Running Command

./bin/seatunnel.sh --config ./task/sftp2sftp

Error Exception

1.Terminal shows that the SFTP connection is not released.
2.Debugging reveals that the file stream is not closed when the SFTPInputStream.close method is triggered.

Zeta or Flink or Spark Version

No response

Java or Scala Version

jdk8

Screenshots

1706780364018
1706780493923
1.The initialization of SFTPInputStream.class does not pass the file stream to the parent class FSInputStream.class
2.the SFTPInputStream.close method only triggers the FSInputStream.close method, which is unable to close the file stream actually held by SFTPInputStream.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions