List of usage examples for java.net SocketTimeoutException getMessage
public String getMessage()
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * Expect read timeout, because the bogus server never sends a reply. */// w w w.j ava2 s.c o m @Test(timeout = TEST_TIMEOUT) public void testReadTimeout() throws Exception { try { fs.listFiles(new Path("/"), false); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("Read timed out", e.getMessage()); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * Expect read timeout on a URL that requires auth, because the bogus server * never sends a reply./*from w w w . ja v a2 s.com*/ */ @Test(timeout = TEST_TIMEOUT) public void testAuthUrlReadTimeout() throws Exception { try { fs.getDelegationToken("renewer"); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("Read timed out", e.getMessage()); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * After a redirect, expect read timeout accessing the redirect location, * because the bogus server never sends a reply. *//* ww w.jav a 2 s. c om*/ @Test(timeout = TEST_TIMEOUT) public void testRedirectReadTimeout() throws Exception { startSingleTemporaryRedirectResponseThread(false); try { fs.getFileChecksum(new Path("/file")); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("Read timed out", e.getMessage()); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * Expect connect timeout, because the connection backlog is consumed. *//*from w ww . j a v a2 s . c o m*/ @Test(timeout = TEST_TIMEOUT) public void testConnectTimeout() throws Exception { consumeConnectionBacklog(); try { fs.listFiles(new Path("/"), false); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("connect timed out", e.getMessage()); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * Expect connect timeout on a URL that requires auth, because the connection * backlog is consumed./*from ww w . j a v a 2 s . co m*/ */ @Test(timeout = TEST_TIMEOUT) public void testAuthUrlConnectTimeout() throws Exception { consumeConnectionBacklog(); try { fs.getDelegationToken("renewer"); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("connect timed out", e.getMessage()); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * After a redirect, expect connect timeout accessing the redirect location, * because the connection backlog is consumed. *//* w w w.java 2 s .c om*/ @Test(timeout = TEST_TIMEOUT) public void testRedirectConnectTimeout() throws Exception { startSingleTemporaryRedirectResponseThread(true); try { fs.getFileChecksum(new Path("/file")); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("connect timed out", e.getMessage()); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * On the second step of two-step write, expect read timeout accessing the * redirect location, because the bogus server never sends a reply. *//* www . jav a 2 s. c om*/ @Test(timeout = TEST_TIMEOUT) public void testTwoStepWriteReadTimeout() throws Exception { startSingleTemporaryRedirectResponseThread(false); OutputStream os = null; try { os = fs.create(new Path("/file")); os.close(); // must close stream to force reading the HTTP response os = null; fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("Read timed out", e.getMessage()); } finally { IOUtils.cleanup(LOG, os); } }
From source file:org.apache.hadoop.hdfs.web.TestWebHdfsTimeouts.java
/** * On the second step of two-step write, expect connect timeout accessing the * redirect location, because the connection backlog is consumed. *//*from www . j a va 2 s .c om*/ @Test(timeout = TEST_TIMEOUT) public void testTwoStepWriteConnectTimeout() throws Exception { startSingleTemporaryRedirectResponseThread(true); OutputStream os = null; try { os = fs.create(new Path("/file")); fail("expected timeout"); } catch (SocketTimeoutException e) { assertEquals("connect timed out", e.getMessage()); } finally { IOUtils.cleanup(LOG, os); } }
From source file:com.normalexception.app.rx8club.handler.AvatarLoader.java
/** * Grab the image url as a bitmap//from w ww .j av a2s.co m * @param url The url to grab the bitmap from * @return The image as a bitmap object */ private Bitmap getBitmap(String url) { File f = fileCache.getFile(url); // First check our cache to see if the // image exists Bitmap b = decodeFile(f); if (b != null) return b; // If we got here, the image wasn't cached try { Bitmap bitmap = null; HttpClient httpclient = LoginFactory.getInstance().getClient(); HttpGet hget = ClientUtils.getHttpGet(url); HttpResponse response = httpclient.execute(hget, LoginFactory.getInstance().getHttpContext()); InputStream is = response.getEntity().getContent(); OutputStream os = new FileOutputStream(f); Utils.copyStream(is, os); os.close(); bitmap = decodeFile(f); return bitmap; } catch (IllegalStateException iex) { // No big deal, the image doesn't exist return null; } catch (SocketTimeoutException ex) { Log.w(TAG, "Socket Timedout When Reading " + url); return null; } catch (Exception ex) { Log.e(TAG, ex.getMessage(), ex); return null; } }
From source file:org.xwiki.rendering.internal.macro.rss.DefaultRomeFeedFactory.java
/** * {@inheritDoc}//from w w w .ja va2 s . c om * @see RomeFeedFactory#createFeed(org.xwiki.rendering.macro.rss.RssMacroParameters) */ public SyndFeed createFeed(RssMacroParameters parameters) throws MacroExecutionException { if (StringUtils.isEmpty(parameters.getFeed())) { throw new MacroExecutionException("The required 'feed' parameter is missing"); } SyndFeedInput syndFeedInput = new SyndFeedInput(); SyndFeed feed; try { URLConnection connection = parameters.getFeedURL().openConnection(); connection.setConnectTimeout(TIMEOUT_MILLISECONDS); feed = syndFeedInput.build(new XmlReader(connection)); } catch (SocketTimeoutException ex) { throw new MacroExecutionException( MessageFormat.format("Connection timeout when trying to reach [{0}]", parameters.getFeedURL())); } catch (Exception ex) { throw new MacroExecutionException( MessageFormat.format("Error processing [{0}] : {1}", parameters.getFeedURL(), ex.getMessage()), ex); } if (feed == null) { throw new MacroExecutionException( MessageFormat.format("No feed found at [{0}]", parameters.getFeedURL())); } return feed; }