List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:org.apache.hadoop.hbase.errorhandling.TestTimeoutExceptionInjector.java
/** * Demonstrate TimeoutExceptionInjector semantics -- triggering fires exception and completes * the timer.//from w ww .j a v a2 s . c o m */ @Test(timeout = 60000) public void testStartAfterTrigger() throws InterruptedException { final long time = 10; ForeignExceptionListener listener = Mockito.mock(ForeignExceptionListener.class); TimeoutExceptionInjector timer = new TimeoutExceptionInjector(listener, time); timer.trigger(); try { timer.start(); fail("Timer should fail to start after complete."); } catch (IllegalStateException e) { LOG.debug("Correctly failed timer: " + e.getMessage()); } Thread.sleep(time * 2); Mockito.verify(listener, Mockito.times(1)).receive(Mockito.any(ForeignException.class)); Mockito.verifyNoMoreInteractions(listener); }
From source file:org.duracloud.sync.monitor.DirectoryUpdateMonitor.java
/** * Starts the monitor watching for updates. *///from w w w .j av a2 s . c o m public void startMonitor() { logger.info("Starting Directory Update Monitor"); try { monitor.start(); } catch (IllegalStateException e) { logger.info("File alteration monitor is already started: " + e.getMessage()); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:org.duracloud.sync.monitor.DirectoryUpdateMonitor.java
/** * Stops the monitor, no further updates will be reported. *//*from ww w . j a va 2 s .com*/ public void stopMonitor() { logger.info("Stopping Directory Update Monitor"); try { monitor.stop(); } catch (IllegalStateException e) { logger.info("File alteration monitor is already stopped: " + e.getMessage()); } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
From source file:com.cimmyt.csv.FileManagerCSVImpl.java
/** * Method that load file in different type of browser * @param media// ww w .j ava 2 s. co m * @return */ private Reader getReader(Media media) { Reader reader = null; try { reader = new InputStreamReader(IOUtils.toInputStream(media.getStringData())); return reader; } catch (IllegalStateException ex) { logger.error(ex.getMessage()); } try { reader = media.getReaderData(); return reader; } catch (IllegalStateException ex) { logger.error(ex.getMessage()); ; } try { reader = new InputStreamReader(media.getStreamData()); return reader; } catch (IllegalStateException ex) { ex.printStackTrace(); } return reader; }
From source file:com.sun.faces.lifecycle.UpdateModelValuesPhase.java
public void execute(FacesContext facesContext) { if (log.isDebugEnabled()) { log.debug("Entering UpdateModelValuesPhase"); }/*from w ww . ja v a 2s. co m*/ UIComponent component = facesContext.getViewRoot(); Util.doAssert(null != component); String exceptionMessage = null; try { component.processUpdates(facesContext); } catch (IllegalStateException e) { exceptionMessage = e.getMessage(); } catch (FacesException fe) { exceptionMessage = fe.getMessage(); } if (null != exceptionMessage) { Object[] params = new Object[3]; params[2] = exceptionMessage; facesContext.addMessage(component.getClientId(facesContext), MessageFactory.getMessage(facesContext, Util.MODEL_UPDATE_ERROR_MESSAGE_ID, params)); if (log.isErrorEnabled()) { log.error(exceptionMessage); } if (log.isDebugEnabled()) { log.debug("Exiting UpdateModelValuesPhase"); } } }
From source file:fr.paris.lutece.plugins.mylutece.modules.oauth.authentication.JSONCredentialRetriever.java
/** * Reads the responses and returns it as String * @param httpResponse the response to read * @return the String./*from w w w .j av a 2 s. com*/ */ private String readResponse(HttpResponse httpResponse) { BufferedReader buffer = null; try { StringBuilder sbResponse = new StringBuilder(); InputStreamReader streamReader = new InputStreamReader(httpResponse.getEntity().getContent()); buffer = new BufferedReader(streamReader); String line = buffer.readLine(); while (line != null) { sbResponse.append(line); line = buffer.readLine(); } return sbResponse.toString(); } catch (IllegalStateException e) { AppLogService.error(e.getMessage(), e); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } finally { if (buffer != null) { try { buffer.close(); } catch (IOException e) { AppLogService.error(e.getMessage(), e); } } } return null; }
From source file:net.pms.io.OutputTextConsumer.java
public void run() { LineIterator it = null;//from w w w . j a v a2 s . c o m try { it = IOUtils.lineIterator(inputStream, "UTF-8"); while (it.hasNext()) { String line = it.nextLine(); if (line.length() > 0) { addLine(line); } if (log) { logger.debug(line); } } } catch (IOException ioe) { logger.debug("Error consuming input stream: {}", ioe.getMessage()); } catch (IllegalStateException ise) { logger.debug("Error reading from closed input stream: {}", ise.getMessage()); } finally { LineIterator.closeQuietly(it); // clean up all associated resources } }
From source file:org.eclipse.gyrex.cloud.internal.zk.ZooKeeperPinger.java
private synchronized void setStatus(final IStatus status) { try {/* ww w .ja v a 2 s . c o m*/ if (null != serviceRegistration) { serviceRegistration.unregister(); serviceRegistration = null; } if ((null != status) && !status.isOK()) { serviceRegistration = CloudActivator.getInstance().getServiceHelper().registerService( IStatusConstants.SERVICE_NAME, status, "Eclipse Gyrex", "ZooKeeper Connection Status", STATUS_PID, null); } } catch (final IllegalStateException e) { LOG.warn("Unable to update ZooKeeper connection status. {}", e.getMessage()); } }
From source file:se.carlengstrom.internetonastick.http.HttpServer.java
private String getMarkov(final Request req, final Response res) throws JsonProcessingException { final String user = req.params("user"); final String markovName = req.params("markov"); final Markov markov = markovs.get(user).get(markovName); if (markov != null) { try {// w ww . j ava 2s . com return mapper.writeValueAsString( new SentenceResponseBuilder().sentence(markov.generateSentence()).build()); } catch (IllegalStateException ise) { res.status(500); return ise.getMessage(); } } else { return "GET here with a valid markov name to get a sentence"; } }
From source file:net.shopxx.service.impl.ThemeServiceImpl.java
public boolean upload(MultipartFile multipartFile) { if (multipartFile == null || multipartFile.isEmpty()) { return false; }//from w ww . j a v a 2 s. c o m File tempThemeFile = new File(FileUtils.getTempDirectory(), UUID.randomUUID() + ".tmp"); File tempThemeDir = new File(FileUtils.getTempDirectory(), UUID.randomUUID().toString()); try { multipartFile.transferTo(tempThemeFile); CompressUtils.extract(tempThemeFile, tempThemeDir); File themeXmlFile = new File(tempThemeDir, "/template/theme.xml"); if (themeXmlFile.exists() && themeXmlFile.isFile()) { Theme theme = get(themeXmlFile); if (theme != null && StringUtils.isNotEmpty(theme.getId())) { FileUtils.moveDirectory(new File(tempThemeDir, "/template"), new File(servletContext.getRealPath(themeTemplatePath), theme.getId())); FileUtils.moveDirectory(new File(tempThemeDir, "/resources"), new File(servletContext.getRealPath(themeResourcePath), theme.getId())); return true; } } } catch (IllegalStateException e) { throw new RuntimeException(e.getMessage(), e); } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } finally { FileUtils.deleteQuietly(tempThemeFile); FileUtils.deleteQuietly(tempThemeDir); } return false; }