高并发测试期间的IO异常

时间:2018-08-08 07:19:36

标签: java multithreading spring-boot concurrency audioinputstream

我设置了100个线程来测试我的服务5分钟,这会引发一些IOExceptions(错误率约为10%)。以下是导致错误的代码段:

public class SoundServiceImpl implements SoundService {
   ... ...
   public String editSound(String url)){
   ... ...
   try {
        URL urlFile = new URL(url);
        stream = AudioSystem.getAudioInputStream(urlFile);
    } catch (UnsupportedAudioFileException e) {
        logger.error("UnsupportedAudioFileException, error happen when getting InputStream", e);
    } catch (IOException e) {
        logger.error("IOException, error happen when getting InputStream", e);
    }
    ... ...

这是日志:

ERROR 236112 --- [ULT-8-thread-31] c.a.a.provider.SoundServiceImpl: 
    IOException, error happen when getting InputStream

    java.net.ConnectException: Connection timed out: connect
    at java.net.DualStackPlainSocketImpl.connect0(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
    at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.<init>(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.http.HttpClient.New(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown
    Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Sou
    rce)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Sour
    ce)
    at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown S
    ource)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown So
    urce)
    at java.net.URL.openStream(Unknown Source)
    at javazoom.spi.vorbis.sampled.file.VorbisAudioFileReader.getAudioInputS
    tream(Unknown Source)
    at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source)
    at com.alibaba.ailabs.hsf.provider.SoundServiceImpl.editSound(SoundServi
    ceImpl.java:53)
    at sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    ... ...

我的服务输入是一个音乐URL(“ http://rpg.hamsterrepublic.com/wiki-images/3/3e/Heal8-Bit.ogg”),我很困惑,为什么在高并发情况下我的服务会在这里抛出异常。谁能给我一些提示或可能的原因?

0 个答案:

没有答案