List of usage examples for java.lang IllegalStateException getMessage
public String getMessage()
From source file:com.blackducksoftware.integration.hub.detect.detector.gradle.GradleReportParser.java
public Optional<DetectCodeLocation> parseDependencies(final File codeLocationFile) { DetectCodeLocation codeLocation = null; String projectSourcePath = ""; String projectGroup = ""; String projectName = ""; String projectVersionName = ""; boolean processingMetaData = false; final MutableDependencyGraph graph = new MutableMapDependencyGraph(); final DependencyHistory history = new DependencyHistory(); try (FileInputStream dependenciesInputStream = new FileInputStream(codeLocationFile); BufferedReader reader = new BufferedReader( new InputStreamReader(dependenciesInputStream, StandardCharsets.UTF_8));) { while (reader.ready()) { final String line = reader.readLine(); /**/*w w w.j ava2s . c o m*/ * The meta data section will be at the end of the file after all of the "gradle dependencies" output */ if (line.startsWith(DETECT_META_DATA_HEADER)) { processingMetaData = true; continue; } if (line.startsWith(DETECT_META_DATA_FOOTER)) { processingMetaData = false; continue; } if (processingMetaData) { if (line.startsWith(PROJECT_PATH_PREFIX)) { projectSourcePath = line.substring(PROJECT_PATH_PREFIX.length()).trim(); } else if (line.startsWith(PROJECT_GROUP_PREFIX)) { projectGroup = line.substring(PROJECT_GROUP_PREFIX.length()).trim(); } else if (line.startsWith(PROJECT_NAME_PREFIX)) { projectName = line.substring(PROJECT_NAME_PREFIX.length()).trim(); } else if (line.startsWith(PROJECT_VERSION_PREFIX)) { projectVersionName = line.substring(PROJECT_VERSION_PREFIX.length()).trim(); } continue; } if (StringUtils.isBlank(line)) { history.clear(); gradleReportConfigurationParser = new GradleReportConfigurationParser(); continue; } final Dependency dependency = gradleReportConfigurationParser.parseDependency(externalIdFactory, line); if (dependency == null) { continue; } final int lineTreeLevel = gradleReportConfigurationParser.getTreeLevel(); try { history.clearDependenciesDeeperThan(lineTreeLevel); } catch (final IllegalStateException e) { logger.warn(String.format("Problem parsing line '%s': %s", line, e.getMessage())); } if (history.isEmpty()) { graph.addChildToRoot(dependency); } else { graph.addChildWithParents(dependency, history.getLastDependency()); } history.add(dependency); } final ExternalId id = externalIdFactory.createMavenExternalId(projectGroup, projectName, projectVersionName); codeLocation = new DetectCodeLocation.Builder(DetectCodeLocationType.GRADLE, projectSourcePath, id, graph).build(); } catch (final IOException e) { codeLocation = null; } return Optional.ofNullable(codeLocation); }
From source file:com.github.springtestdbunit.TestExecutionListenerChainTests.java
@Test public void shouldNotCreateWithIllegalConstructor() throws Exception { try {//from www . j a v a 2 s.c om this.chain = new TestExecutionListenerChain() { @Override protected Class<?>[] getChain() { return new Class<?>[] { InvalidTestListener.class }; }; }; fail(); } catch (IllegalStateException e) { assertEquals("Unable to create chain for classes [class com.github.springtestdbunit." + "TestExecutionListenerChainTests$InvalidTestListener]", e.getMessage()); } }
From source file:com.github.springtestdbunit.TestExecutionListenerChainTest.java
@Test public void shouldNotCreateWithIllegalConstructor() throws Exception { try {//from w w w. ja v a2 s . com this.chain = new TestExecutionListenerChain() { @Override protected Class<?>[] getChain() { return new Class<?>[] { InvalidTestListener.class }; }; }; fail(); } catch (IllegalStateException ex) { assertEquals("Unable to create chain for classes [class com.github.springtestdbunit." + "TestExecutionListenerChainTest$InvalidTestListener]", ex.getMessage()); } }
From source file:org.sakaiproject.kernel.webapp.filter.SakaiRequestFilter.java
/** * *//*from ww w. j a v a 2 s . c o m*/ protected void rollback() { try { transactionManager.rollback(); } catch (IllegalStateException e) { if (debug) LOG.debug(e); } catch (Exception e) { LOG.error(e.getMessage(), e); } }
From source file:org.arquillian.extension.recorder.screenshooter.browser.impl.BrowserScreenshooter.java
private WebDriver getTakingScreenshotsBrowser(File screenshotToTake) { WebDriver result = null;// ww w . jav a 2s. co m try { GrapheneContext context = GrapheneContext.getContextFor(Default.class); result = ((GrapheneProxyInstance) context.getWebDriver(TakesScreenshot.class)).unwrap(); //FIXME remove this try-catch block and bring new solution } catch (IllegalStateException ex) { log.info("The screenshot " + screenshotToTake.getPath() + " hasn't been taken." + " The reason: " + ex.getMessage()); return null; } if (result instanceof ReusableRemoteWebDriver) { result = new Augmenter().augment(result); } return result; }
From source file:org.apache.nifi.registry.web.mapper.IllegalStateExceptionMapper.java
@Override public Response toResponse(IllegalStateException exception) { // log the error logger.info(String.format("%s. Returning %s response.", exception, Response.Status.CONFLICT)); if (logger.isDebugEnabled()) { logger.debug(StringUtils.EMPTY, exception); }/* www. j a v a2 s . co m*/ return Response.status(Response.Status.CONFLICT).entity(exception.getMessage()).type("text/plain").build(); }
From source file:org.grails.orm.hibernate.support.HibernatePersistenceContextInterceptor.java
public void reconnect() { if (getSessionFactory() == null) return;//w ww . j av a 2s. com Connection connection = ((SessionImpl) getSession()).connection(); Session session = getSession(); if (!session.isConnected()) { try { getSession().reconnect(connection); } catch (IllegalStateException e) { // cannot reconnect on different exception. ignore LOG.debug(e.getMessage(), e); } } }
From source file:org.apache.hadoop.conf.TestConfiguration.java
private static void checkSubDepthException(Configuration configuration, String key) { try {//w ww . j a v a 2s.c o m configuration.get(key); fail("IllegalStateException depth too large not thrown"); } catch (IllegalStateException e) { assertTrue("Unexpected exception text: " + e, e.getMessage().contains("substitution depth")); } }
From source file:org.dspace.utils.servlet.DSpaceWebappServletFilter.java
public void init(FilterConfig filterConfig) throws ServletException { // ensure the kernel is running, if not then we have to die here try {//from w ww.jav a 2 s . co m getKernel(); String param = filterConfig.getInitParameter("paths-to-be-ignored"); pathsToBeIgnored = new ArrayList<String>(); if (null != StringUtils.trimToNull(param)) { String[] items = StringUtils.split(param, ';'); for (String item : items) { pathsToBeIgnored.add(item); } } } catch (IllegalStateException e) { // no kernel so we die String message = "Could not start up DSpaceWebappServletFilter because the DSpace Kernel is unavailable or not running: " + e.getMessage(); System.err.println(message); throw new ServletException(message, e); } }
From source file:org.apache.rave.portal.service.impl.DefaultOmdlService.java
@Override public Page importOmdl(MultipartFile multipartFile, String pageName) throws DuplicateItemException { Page page = null;//from ww w.j a va 2 s . co m OmdlInputAdapter omdlInputAdapter = new OmdlInputAdapter(); File temp = null; String xml = null; try { if (multipartFile != null) { if (multipartFile.getSize() > 0) { String tempUploadFolder = System.getProperty("java.io.tmpdir"); temp = new File(tempUploadFolder, multipartFile.getOriginalFilename()); multipartFile.transferTo(temp); xml = FileUtils.readFileToString(temp); } } } catch (IllegalStateException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } catch (IOException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } Document root = initializeBuilder(xml); if (root != null) { try { parseOmdlFile(root, omdlInputAdapter); } catch (BadOmdlXmlFormatException e) { logger.error(e.getMessage()); throw new RuntimeException(e); } } page = pageService.addNewUserPage(pageName, omdlInputAdapter.getLayoutCode()); switch (page.getRegions().size()) { case 1: populateRegionWidgets(page, omdlInputAdapter.getAllUrls(), page.getRegions().get(0).getId()); break; case 2: populateRegionWidgets(page, omdlInputAdapter.getAllLeftUrls(), page.getRegions().get(0).getId()); populateRegionWidgets(page, omdlInputAdapter.getAllRightUrls(), page.getRegions().get(1).getId()); break; case 3: populateRegionWidgets(page, omdlInputAdapter.getAllLeftUrls(), page.getRegions().get(0).getId()); populateRegionWidgets(page, omdlInputAdapter.getAllCenterUrls(), page.getRegions().get(1).getId()); populateRegionWidgets(page, omdlInputAdapter.getAllRightUrls(), page.getRegions().get(2).getId()); break; case 4: populateRegionWidgets(page, omdlInputAdapter.getAllLeftUrls(), page.getRegions().get(0).getId()); populateRegionWidgets(page, omdlInputAdapter.getAllCenterUrls(), page.getRegions().get(1).getId()); populateRegionWidgets(page, omdlInputAdapter.getAllRightUrls(), page.getRegions().get(2).getId()); populateRegionWidgets(page, omdlInputAdapter.getAllUnknownUrls(), page.getRegions().get(3).getId()); break; default: // there are no layouts with more than 4 regions at present } return page; }