SocketException:Socket已关闭

时间:2013-05-01 21:46:23

标签: java

现在忍受我,因为这是一个奇怪的情况。我的项目是使用JDK1.4编写和编译的,它使用Apache的HTTPClient(折旧的)来处理HTTP / HTTPS连接。对于我们的下一个版本,我们将升级到IBM Websphere 7,并且我们的Web服务应用程序将在JRE6上运行。在进行一些测试时,我在加载“https://myaccounts.navyfcu.org/cgi-bin/ifsewwwc”时遇到了问题。在迭代GZInputStream时发生SocketException。我已经检查过我们实际上正在使用HTTP协议1.1,并且请求和响应标头与我在HTTPFox中看到的匹配。将运行时环境设置为JRE4时,这不是问题,这是我们列表中唯一遇到此问题的URL。任何帮助将不胜感激。

EDIT 添加了代码以供参考。

protected void load( java.io.InputStream input ) throws java.io.IOException, com.paytrust.Bot.ProcessCancelledException
{
    if( null == input )
        throw new NullPointerException( "Non-null input stream expected" );

    // Clear data
    m_content = null; // String that holds the HTML
    m_lowerCaseContent = null; // Tracks m_content
    resetIndex(); 

    // Load
    final int XFER_BLOCK_SIZE = 4096;
    char[] xferBuff = new char[XFER_BLOCK_SIZE];
    InputStreamReader inputStreamReader = null;
    BufferedReader bufferedReader = null;
    try
    {        
        inputStreamReader = new InputStreamReader( input );   // Translate to Unicode characters
        bufferedReader = new BufferedReader( inputStreamReader, XFER_BLOCK_SIZE );      // Buffer the stream 

        int numCharsRead = 0;
        StringBuffer stringBuff = new StringBuffer( 2 * XFER_BLOCK_SIZE );   
        while( ( numCharsRead = bufferedReader.read( xferBuff, 0, XFER_BLOCK_SIZE ) ) != -1 )
            stringBuff.append( xferBuff, 0, numCharsRead ); 
        if( 0 != stringBuff.length() )
            m_content = stringBuff.toString();  
    }
    finally
    {
        // Free resources
        if( bufferedReader != null )
            bufferedReader.close();
        if( inputStreamReader != null )
            inputStreamReader.close(); 
    }    
}

0 个答案:

没有答案
相关问题