Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala S3AbortableInputStream:并非所有字节都是从S3ObjectInputStream读取的_Scala_Amazon Web Services_Amazon S3 - Fatal编程技术网

Scala S3AbortableInputStream:并非所有字节都是从S3ObjectInputStream读取的

Scala S3AbortableInputStream:并非所有字节都是从S3ObjectInputStream读取的,scala,amazon-web-services,amazon-s3,Scala,Amazon Web Services,Amazon S3,我在执行s3获取对象请求时收到此警告 WARN S3AbortableInputStream: Not all bytes were read from the S3ObjectInputStream, aborting HTTP connection. This is likely an error and may result in sub-optimal behavior. Request only the bytes you need via a ranged GET or dra

我在执行s3获取对象请求时收到此警告

WARN S3AbortableInputStream: Not all bytes were read from the 
S3ObjectInputStream, aborting HTTP connection. This is likely an error 
and may result in sub-optimal behavior. Request only the bytes you 
need via a ranged GET or drain the input stream after use
我看着

我不清楚需要做什么

下面是我正在使用的代码片段

 try {
    s3obj = s3Client.getObject(s3Bucket, objectSummary.getKey)
    val name = s3obj.getKey.substring(dirPath.length + 1)
    val filename = name.replace(".xml", "")
    endpoints += base_url + filename
  } catch {
    case e@(_: IOException |_ : JSONException | _: Exception) =>
      println(e)
  } finally {
    if (s3obj != null)
      s3obj.close()
  }

基本上,它所做的是,如果S3客户端在读取N个字节后试图关闭InputStream而没有完全使用它,它会发出警告消息,因为它们需要关闭HttpRequest和底层http连接,并从连接池中删除连接。
当:
Web应用程序最初从S3读取数据,S3数据存储通常将数据缓存在本地文件系统中。在这种情况下,如果Web访问者断开HTTP连接,并且Tomcat指示断开连接,则HTTP处理线程将停止,结果,InputStream将关闭

请参阅以下连结:

如果您添加

  s3obj.abort()
对于异常块,它应该可以解决该问题。它看起来是这样的:

  } catch {
    case e@(_: IOException |_ : JSONException | _: Exception) =>
      println(e)
      if (s3obj != null) {
        s3obj.abort()
      }
  } finally {
    if (s3obj != null)
      s3obj.close()
  }

AWS SDK的复杂性在于,它希望避免在不必要时进行正常的close()操作来缩短大量数据流。

感谢您的回复。在我的案例中,我需要做什么来修复警告?请解释解决方案