2014-10-03 337 views
4

這是什麼原因?什麼原因導致com.aerospike.client.AerospikeException:java.io.EOFException?

com.aerospike.client.AerospikeException: java.io.EOFException 
    at com.aerospike.client.async.SelectorManager.processKey(SelectorManager.java:184) [aerospike-client-3.0.24.jar:?] 
    at com.aerospike.client.async.SelectorManager.runCommands(SelectorManager.java:108) [aerospike-client-3.0.24.jar:?] 
    at com.aerospike.client.async.SelectorManager.run(SelectorManager.java:69) [aerospike-client-3.0.24.jar:?] 
Caused by: java.io.EOFException 
    at com.aerospike.client.async.AsyncConnection.read(AsyncConnection.java:127) ~[aerospike-client-3.0.24.jar:?] 
    at com.aerospike.client.async.AsyncSingleCommand.read(AsyncSingleCommand.java:48) ~[aerospike-client-3.0.24.jar:?] 
    at com.aerospike.client.async.SelectorManager.processKey(SelectorManager.java:164) ~[aerospike-client-3.0.24.jar:?] 
    ... 2 more 
+2

沒有任何導致異常的代碼,這也可能是一個修辭問題。 – 2014-10-03 18:19:34

+0

這個問題針對的是aerospike的實現者 - 不是一般的java問題。如果你能拿掉你對這個問題的投票權,我會很感激。 – andersonbd1 2014-10-03 18:22:46

+2

然後,您應該先閱讀發佈StackOverflow的準則並編輯您的問題以符合規則。無論你的問題是關於一般的Java函數還是一個庫,你都不能問「爲什麼我得到這個異常?」如果你不會告訴我們你在做什麼導致它。 – 2014-10-04 18:42:03

回答

6

當套接字連接不再有效時引發EOFException。通常會發生這種情況,因爲服務器已關閉連接。

/** 
* Read till byteBuffer limit reached or received would-block. 
*/ 
public boolean read(ByteBuffer byteBuffer) throws IOException { 
    while (byteBuffer.hasRemaining()) { 
     int len = socketChannel.read(byteBuffer); 

     if (len == 0) {   
      // Got would-block. 
      return false; 
     } 

     if (len < 0) { 
      // Server has shutdown socket. 
       throw new EOFException(); 
     } 
    } 
    return true; 
} 
+2

關於關閉連接的更多細節EOFException可以在以下Aerospike討論主題中找到 - https://discuss.aerospike.com/t/what-c​​auses-aerospikeexception-java-io-eofexception/444/12 – 2016-10-20 14:26:48

相關問題