List of usage examples for java.io InterruptedIOException getMessage
public String getMessage()
From source file:org.psikeds.common.services.AbstractRESTService.java
protected Response buildResponse(final InterruptedIOException ioex) { return buildResponse(Status.REQUEST_TIMEOUT, ioex.getMessage()); }
From source file:net.pms.io.PipeIPCProcess.java
@Override public void run() { byte[] b = new byte[512 * 1024]; int n = -1;/*from www . j ava2s. com*/ InputStream in = null; OutputStream out = null; OutputStream debug = null; try { in = mkin.getInputStream(); out = mkout.getOutputStream(); if (modifier != null && modifier.isH264AnnexB()) { in = new H264AnnexBInputStream(in, modifier.getHeader()); } else if (modifier != null && modifier.isEncodedAudioPassthrough()) { out = new IEC61937AudioOutputStream(new PCMAudioOutputStream(out, modifier.getNbChannels(), modifier.getSampleFrequency(), modifier.getBitsPerSample())); } else if (modifier != null && modifier.isDtsEmbed()) { out = new DTSAudioOutputStream(new PCMAudioOutputStream(out, modifier.getNbChannels(), modifier.getSampleFrequency(), modifier.getBitsPerSample())); } else if (modifier != null && modifier.isPcm()) { out = new PCMAudioOutputStream(out, modifier.getNbChannels(), modifier.getSampleFrequency(), modifier.getBitsPerSample()); } if (modifier != null && modifier.getHeader() != null && !modifier.isH264AnnexB()) { out.write(modifier.getHeader()); } while ((n = in.read(b)) > -1) { out.write(b, 0, n); if (debug != null) { debug.write(b, 0, n); } } } catch (InterruptedIOException e) { if (LOGGER.isDebugEnabled()) { if (isNotBlank(e.getMessage())) { LOGGER.debug("IPC pipe interrupted after writing {} bytes, shutting down: {}", e.bytesTransferred, e.getMessage()); } else { LOGGER.debug("IPC pipe interrupted after writing {} bytes, shutting down...", e.bytesTransferred); } LOGGER.trace("", e); } } catch (IOException e) { LOGGER.warn("An error occurred duing IPC piping: {}", e.getMessage()); LOGGER.trace("", e); } finally { try { // in and out may not have been initialized: // http://ps3mediaserver.org/forum/viewtopic.php?f=6&t=9885&view=unread#p45142 if (in != null) { in.close(); } if (out != null) { out.close(); } if (debug != null) { debug.close(); } } catch (IOException e) { LOGGER.debug("Error closing IPC pipe streams: {}" + e.getMessage()); LOGGER.trace("", e); } } }
From source file:com.silverpeas.openoffice.windows.webdav.WebdavManager.java
/** * Get the ressource from the webdav server. * * @param uri the uri to the ressource.// w w w . j a v a 2s . c o m * @param lockToken the current lock token. * @return the path to the saved file on the filesystem. * @throws IOException */ public String getFile(URI uri, String lockToken) throws IOException { GetMethod method = executeGetFile(uri); String fileName = uri.getPath(); fileName = fileName.substring(fileName.lastIndexOf('/') + 1); fileName = URLDecoder.decode(fileName, "UTF-8"); UIManager.put("ProgressMonitor.progressText", MessageUtil.getMessage("download.file.title")); ProgressMonitorInputStream is = new ProgressMonitorInputStream(null, MessageUtil.getMessage("downloading.remote.file") + ' ' + fileName, new BufferedInputStream(method.getResponseBodyAsStream())); fileName = fileName.replace(' ', '_'); ProgressMonitor monitor = is.getProgressMonitor(); monitor.setMaximum(new Long(method.getResponseContentLength()).intValue()); monitor.setMillisToDecideToPopup(0); monitor.setMillisToPopup(0); File tempDir = new File(System.getProperty("java.io.tmpdir"), "silver-" + System.currentTimeMillis()); tempDir.mkdirs(); File tmpFile = new File(tempDir, fileName); FileOutputStream fos = new FileOutputStream(tmpFile); byte[] data = new byte[64]; int c = 0; try { while ((c = is.read(data)) > -1) { fos.write(data, 0, c); } } catch (InterruptedIOException ioinex) { logger.log(Level.INFO, "{0} {1}", new Object[] { MessageUtil.getMessage("info.user.cancel"), ioinex.getMessage() }); unlockFile(uri, lockToken); System.exit(0); } finally { fos.close(); } return tmpFile.getAbsolutePath(); }
From source file:org.tinymediamanager.scraper.util.Url.java
/** * Gets the input stream./*from ww w . j a va 2s. c o m*/ * * @return the input stream * @throws IOException * Signals that an I/O exception has occurred. */ public InputStream getInputStream() throws IOException, InterruptedException { // workaround for local files if (url.startsWith("file:")) { String newUrl = url.replace("file:/", ""); File file = new File(newUrl); return new FileInputStream(file); } BasicHttpContext localContext = new BasicHttpContext(); ByteArrayInputStream is = null; // replace our API keys for logging... String logUrl = url.replaceAll("api_key=\\w+", "api_key=<API_KEY>").replaceAll("api/\\d+\\w+", "api/<API_KEY>"); LOGGER.debug("getting " + logUrl); HttpGet httpget = new HttpGet(uri); RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(10000).setConnectTimeout(10000) .build(); httpget.setConfig(requestConfig); // set custom headers for (Header header : headersRequest) { httpget.addHeader(header); } CloseableHttpResponse response = null; try { response = client.execute(httpget, localContext); headersResponse = response.getAllHeaders(); entity = response.getEntity(); responseStatus = response.getStatusLine(); if (entity != null) { is = new ByteArrayInputStream(EntityUtils.toByteArray(entity)); } EntityUtils.consume(entity); } catch (InterruptedIOException e) { LOGGER.info("aborted request (" + e.getMessage() + "): " + logUrl); throw e; } catch (UnknownHostException e) { LOGGER.error("proxy or host not found/reachable", e); throw e; } catch (Exception e) { LOGGER.error("Exception getting url " + logUrl, e); } finally { if (response != null) { response.close(); } } return is; }
From source file:com.mirth.connect.connectors.tcp.TcpMessageReceiver.java
public void run() { while (!disposing.get()) { if (connector.isStarted() && !disposing.get()) { Socket socket = null; try { socket = serverSocket.accept(); logger.trace("Server socket Accepted on: " + serverSocket.getLocalPort()); } catch (java.io.InterruptedIOException iie) { logger.debug("Interupted IO doing serverSocket.accept: " + iie.getMessage()); } catch (Exception e) { if (!connector.isDisposed() && !disposing.get()) { logger.warn("Accept failed on socket: " + e, e); handleException(new ConnectException(e, this)); }/* w w w . jav a 2 s . c om*/ } if (socket != null) { try { monitoringController.updateStatus(connector, connectorType, Event.CONNECTED, socket); work = (TcpWorker) createWork(socket); try { getWorkManager().scheduleWork(work, WorkManager.IMMEDIATE, null, null); } catch (WorkException e) { logger.error("Tcp Server receiver Work was not processed: " + e.getMessage(), e); } } catch (SocketException e) { alertController.sendAlerts(((TcpConnector) connector).getChannelId(), Constants.ERROR_411, null, e); monitoringController.updateStatus(connector, connectorType, Event.DISCONNECTED, socket); handleException(e); } } } } }
From source file:org.teleal.cling.transport.impl.apache.StreamServerImpl.java
public void run() { log.fine("Entering blocking receiving loop, listening for HTTP stream requests on: " + serverSocket.getLocalSocketAddress()); while (!stopped) { try {// w w w . j a v a2 s.co m // Block until we have a connection Socket clientSocket = serverSocket.accept(); log.fine("Incoming connection from: " + clientSocket.getInetAddress()); // if (HTTPServerData.HOST != null // && // !clientSocket.getInetAddress().getHostAddress().equals(HTTPServerData.HOST) // && !configuration.isExported()) { // clientSocket.close(); // continue; // } // We have to force this fantastic library to accept HTTP // methods which are not in the holy RFCs. DefaultHttpServerConnection httpServerConnection = new DefaultHttpServerConnection() { @Override protected HttpRequestFactory createHttpRequestFactory() { return new UpnpHttpRequestFactory(); } }; httpServerConnection.bind(clientSocket, globalParams); // Wrap the processing of the request in a UpnpStream UpnpStream connectionStream = new HttpServerConnectionUpnpStream(router.getProtocolFactory(), httpServerConnection, globalParams); router.received(connectionStream); } catch (InterruptedIOException ex) { log.info("I/O has been interrupted, stopping receiving loop, bytes transfered: " + ex.bytesTransferred); break; } catch (SocketException ex) { if (!stopped) { // That's not good, could be anything log.info("Exception using server socket: " + ex.getMessage()); } else { // Well, it's just been stopped so that's totally fine and // expected } break; } catch (IOException ex) { log.info("Exception initializing receiving loop: " + ex.getMessage()); break; } } try { log.fine("Receiving loop stopped"); if (!serverSocket.isClosed()) { log.fine("Closing streaming server socket"); serverSocket.close(); } } catch (Exception ex) { log.info("Exception closing streaming server socket: " + ex.getMessage()); } }
From source file:com.zte.ums.zenap.itm.agent.plugin.linux.util.cli.TelnetSession.java
@Override protected String waitfor(String[] as) throws IOException { byte abyte0[] = new byte[readBufferLength]; int j = 0;//from w w w. ja v a 2 s . co m String s = ""; long starttime = System.currentTimeMillis(); while (System.currentTimeMillis() - starttime < timeout) { if (getInputStream().available() > 0) { try { j = getInputStream().read(abyte0); } catch (InterruptedIOException interruptedioexception) { if (j > 0) s = s + new String(abyte0, 0, j); if (!cmdEcho || !promptEcho) s = truncateResponse(s); partialData = s; throw new IOException(interruptedioexception.getMessage()); } s = s + new String(abyte0, 0, j); int k = match(s, as); if (k >= 0) { partialData = null; if (!cmdEcho || !promptEcho) { prompt = as[k]; s = truncateResponse(s); } return s; } } else { try { Thread.sleep(500); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } } } return null; }
From source file:org.fourthline.cling.transport.impl.apache.StreamServerImpl.java
public void run() { log.fine("Entering blocking receiving loop, listening for HTTP stream requests on: " + serverSocket.getLocalSocketAddress()); while (!stopped) { try {// www .j av a 2 s . c o m // Block until we have a connection final Socket clientSocket = serverSocket.accept(); // We have to force this fantastic library to accept HTTP methods which are not in the holy RFCs. final DefaultHttpServerConnection httpServerConnection = new DefaultHttpServerConnection() { @Override protected HttpRequestFactory createHttpRequestFactory() { return new UpnpHttpRequestFactory(); } }; log.fine("Incoming connection from: " + clientSocket.getInetAddress()); httpServerConnection.bind(clientSocket, globalParams); // Wrap the processing of the request in a UpnpStream UpnpStream connectionStream = new HttpServerConnectionUpnpStream(router.getProtocolFactory(), httpServerConnection, globalParams) { @Override protected Connection createConnection() { return new ApacheServerConnection(clientSocket, httpServerConnection); } }; router.received(connectionStream); } catch (InterruptedIOException ex) { log.fine("I/O has been interrupted, stopping receiving loop, bytes transfered: " + ex.bytesTransferred); break; } catch (SocketException ex) { if (!stopped) { // That's not good, could be anything log.fine("Exception using server socket: " + ex.getMessage()); } else { // Well, it's just been stopped so that's totally fine and expected } break; } catch (IOException ex) { log.fine("Exception initializing receiving loop: " + ex.getMessage()); break; } } try { log.fine("Receiving loop stopped"); if (!serverSocket.isClosed()) { log.fine("Closing streaming server socket"); serverSocket.close(); } } catch (Exception ex) { log.info("Exception closing streaming server socket: " + ex.getMessage()); } }
From source file:com.zte.ums.zenap.itm.agent.plugin.linux.util.cli.TelnetSession.java
@Override protected String waitfor(String s) throws IOException { boolean flag = false; if (s.length() != 0) scriptHandler.setup(s);//from w ww . j a v a2 s. c om else throw new IOException(" prompt may be empty"); byte abyte0[] = new byte[readBufferLength]; int i = 0; String s1 = ""; log("Parameter to match:" + s); long startTime = System.currentTimeMillis(); while (System.currentTimeMillis() - startTime < timeout) { if (getInputStream().available() > 0) { try { i = getInputStream().read(abyte0); log("Message rcvd:" + new String(abyte0)); } catch (InterruptedIOException interruptedioexception) { if (i > 0) s1 = s1 + new String(abyte0, 0, i); if (!cmdEcho || !promptEcho) s1 = truncateResponse(s1); if (flag) { return s1; } else { partialData = s1; throw new IOException(interruptedioexception.getMessage()); } } s1 = s1 + new String(abyte0, 0, i, "UTF-8"); if (scriptHandler.match(s1, s)) { log("Parameter match SUCCESSFUL:" + s); partialData = null; if (getInputStream().available() > 0) { flag = true; } else { if (!cmdEcho || !promptEcho) s1 = truncateResponse(s1); return s1; } } } else { try { Thread.sleep(500); } catch (InterruptedException e) { throw new IOException(e.getMessage()); } } } return null; }
From source file:com.mirth.connect.connectors.mllp.MllpMessageReceiver.java
public void run() { while (!disposing.get()) { if (connector.isStarted() && !disposing.get()) { Socket socket = null; if (connector.isServerMode()) { try { socket = serverSocket.accept(); logger.trace("Server socket Accepted on: " + serverSocket.getLocalPort()); } catch (java.io.InterruptedIOException iie) { logger.debug("Interupted IO doing serverSocket.accept: " + iie.getMessage()); } catch (Exception e) { if (!connector.isDisposed() && !disposing.get()) { logger.warn("Accept failed on socket: " + e, e); handleException(new ConnectException(e, this)); }/*from ww w .j a v a2s. c o m*/ } } else { // Create the client socket. If it can't create the // client socket, sleep through the reconnect interval and // try again. URI uri = endpoint.getEndpointURI().getUri(); try { clientSocket = createClientSocket(uri); socket = clientSocket; logger.trace("Server socket Accepted on: " + clientSocket.getLocalPort()); } catch (Exception e) { try { logger.debug("Socket connection to " + uri.getHost() + ":" + uri.getPort() + " failed, waiting " + connector.getReconnectInterval() + "ms."); Thread.sleep(connector.getReconnectInterval()); } catch (Exception ex) { } } } if (socket != null) { try { monitoringController.updateStatus(connector, connectorType, Event.CONNECTED, socket); work = (TcpWorker) createWork(socket); if (connector.isServerMode()) { try { getWorkManager().scheduleWork(work, WorkManager.IMMEDIATE, null, null); } catch (WorkException e) { logger.error("Tcp Server receiver Work was not processed: " + e.getMessage(), e); } } else { work.run(); } } catch (SocketException e) { alertController.sendAlerts(((MllpConnector) connector).getChannelId(), Constants.ERROR_408, null, e); monitoringController.updateStatus(connector, connectorType, Event.DISCONNECTED, socket); handleException(e); } } } } }