Example usage for java.lang IllegalStateException getMessage

List of usage examples for java.lang IllegalStateException getMessage

Introduction

In this page you can find the example usage for java.lang IllegalStateException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.sonar.batch.maven.MavenProjectConverterTest.java

/**
 * See SONAR-2681/*from  w  ww.ja  v  a 2 s  .c  o  m*/
 */
@Test
public void shouldThrowExceptionWhenUnableToDetermineProjectStructure() {
    MavenProject root = new MavenProject();
    root.setFile(new File("/foo/pom.xml"));
    root.getBuild().setDirectory("target");
    root.getModules().add("module/pom.xml");

    try {
        converter.configure(Arrays.asList(root), root);
        fail();
    } catch (IllegalStateException e) {
        assertThat(e.getMessage(), containsString("Advanced Reactor Options"));
    }
}

From source file:org.apache.hadoop.hbase.regionserver.metrics.TestSchemaConfigured.java

/** Don't allow requesting metrics before setting table/CF name */
@Test/*from   www. j  ava2 s  .  c o m*/
public void testDelayedInitialization() {
    SchemaConfigured unconfigured = new SchemaConfigured();
    try {
        unconfigured.getSchemaMetrics();
        fail(IllegalStateException.class.getSimpleName() + " expected");
    } catch (IllegalStateException ex) {
        assertTrue("Unexpected exception message: " + ex.getMessage(),
                Pattern.matches(".* metrics requested before .* initialization.*", ex.getMessage()));
        LOG.debug("Expected exception: " + ex.getMessage());
    }

    SchemaMetrics.setUseTableNameInTest(false);
    SchemaConfigured other = new SchemaConfigured(null, TABLE_NAME, CF_NAME);
    other.passSchemaMetricsTo(unconfigured);
    unconfigured.getSchemaMetrics(); // now this should succeed
}

From source file:org.jolokia.request.JmxRequestTest.java

@Test
public void readRequestMultiAttributes() {
    for (JmxReadRequest req : new JmxReadRequest[] {
            (JmxReadRequest) JmxRequestFactory.createGetRequest(
                    "read/java.lang:type=Memory/Heap!/Memory!/Usage,NonHeapMemoryUsage", procParams),
            (JmxReadRequest) JmxRequestFactory
                    .createPostRequest(createMap("type", "read", "mbean", "java.lang:type=Memory", "attribute",
                            Arrays.asList("Heap/Memory/Usage", "NonHeapMemoryUsage")), procParams) }) {
        assertTrue(req.isMultiAttributeMode());

        for (List list : new List[] { (List) req.toJSON().get("attribute"), req.getAttributeNames() }) {
            assertEquals(list.size(), 2);
            assertTrue(list.contains("Heap/Memory/Usage"));
            assertTrue(list.contains("NonHeapMemoryUsage"));
            assertTrue(req.toString().contains("attribute=["));
            try {
                req.getAttributeName();/*from w  ww  . j  ava  2 s . c om*/
                fail();
            } catch (IllegalStateException exp) {
                assertTrue(exp.getMessage().contains("getAttributeNames"));
            }
        }
    }
}

From source file:io.gravitee.gateway.http.vertx.VertxHttpClient.java

@Override
protected void doStop() throws Exception {
    LOGGER.info("Closing HTTP Client for '{}' endpoint [{}]", endpoint.getName(), endpoint.getTarget());

    httpClients.values().stream().forEach(httpClient -> {
        try {//  w  w  w.j  av  a2 s.  c om
            httpClient.close();
        } catch (IllegalStateException ise) {
            LOGGER.warn(ise.getMessage());
        }
    });
}

From source file:com.jana.android.net.AbstractHttpConnection.java

@Override
public InputStream getContent() {

    if (!hasConnection()) {
        return null;
    }/*from w w w.  j  av  a2  s  . c  o m*/

    HttpEntity httpEntity = httpResponse.getEntity();

    try {

        InputStream in = httpEntity.getContent();

        return in;

    } catch (IllegalStateException e) {

        Logger.w("No stream content as it has already been obtained, Error > " + e.getMessage());

        e.printStackTrace();

        return null;
    } catch (IOException e) {

        Logger.w("No stream content as stream could not be created, Error > " + e.getMessage());

        e.printStackTrace();

        return null;
    }
}

From source file:net.sf.ehcache.Statistics.java

/**
 * Clears the statistic counters to 0 for the associated Cache.
 */// ww  w . j  a  va2s  .  co  m

public void clearStatistics() {
    if (cache == null) {
        throw new IllegalStateException("This statistics object no longer references a Cache.");
    }
    try {
        cache.clearStatistics();
    } catch (IllegalStateException e) {
        if (LOG.isDebugEnabled()) {
            LOG.info("Ignoring call because " + e.getMessage());
        }
    }
}

From source file:org.sakaiproject.nakamura.files.pool.GetPoolStructureServlet.java

@Override
protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
        throws ServletException, IOException {
    try {//  w  w  w . j  a  v a  2 s  .co m
        Resource resource = request.getResource();
        Content content = resource.adaptTo(Content.class);
        ContentManager contentManager = resource.adaptTo(ContentManager.class);
        String resourceId = getResourceId(request, content);
        if (resourceId != null) {
            String resourcePath = StorageClientUtils.newPath(content.getPath(), resourceId);
            Content resourceContent = contentManager.get(resourcePath);
            if (resourceContent != null) {
                if (contentManager.hasBody(resourcePath, null)) {
                    LOGGER.debug("Getting Resource Path {} Has Body", resourcePath);
                    StreamHelper streamHelper = new StreamHelper();
                    ServletContext sc = null;
                    try {
                        sc = getServletContext();
                    } catch (IllegalStateException e) {
                        LOGGER.debug(e.getMessage(), e);
                    }
                    streamHelper.stream(request, contentManager, resourceContent, null, response, resource, sc);
                } else {
                    LOGGER.debug("Getting Resource Path {} No Body", resourcePath);
                    response.setContentType("application/json");
                    response.setCharacterEncoding("UTF-8");
                    ExtendedJSONWriter writer = new ExtendedJSONWriter(response.getWriter());
                    ExtendedJSONWriter.writeContentTreeToWriter(writer, resourceContent, false, 0);
                }
            } else {
                response.sendError(HttpServletResponse.SC_NOT_FOUND);
            }
        }
    } catch (JSONException e) {
        LOGGER.warn(e.getMessage(), e);
        throw new ServletException(e.getMessage(), e);
    } catch (StorageClientException e) {
        LOGGER.warn(e.getMessage(), e);
        throw new ServletException(e.getMessage(), e);
    } catch (AccessDeniedException e) {
        response.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
}

From source file:org.carewebframework.ui.filetailer.MainController.java

/**
 * Start the tailer if it is running./* ww w  .  j  a va 2  s  .  com*/
 */
private void startTailer() {
    if (!isTailerStarted) {
        log.trace("Starting file tailer");
        final Comboitem selectedItem = cboLogFiles.getSelectedItem();
        final String logFilePath = selectedItem == null ? null : selectedItem.getLabel();

        if (tailer == null) {
            log.trace("Creating LogFileTailer with " + logFilePath);
            try {
                tailer = new LogFileTailer(logFiles.get(logFilePath), TAIL_INTERVAL, false);
                tailer.addFileTailerListener(tailListener);
            } catch (final FileNotFoundException e) {
                log.error(e.getMessage(), e);
                showMessage("@cwf.filetailer.error.notfound", logFilePath);
                return;
            }
        } else {
            try {
                tailer.changeFile(logFiles.get(logFilePath));
            } catch (final IllegalStateException ise) {
                log.error(ise.getMessage(), ise);
                showMessage("@cwf.filetailer.error.illegalstate", logFilePath);
                return;
            } catch (final FileNotFoundException e) {
                log.error(e.getMessage(), e);
                showMessage("@cwf.filetailer.error.notfound", logFilePath);
                return;
            }
        }
        showMessage("@cwf.filetailer.msg.duration", tailer.getMaxActiveInterval() / 1000);
        timer.setDelay(TIMER_INTERVAL);
        timer.start();
        log.trace("Timer started");
        new Thread(tailer).start();
        log.trace("Tailer started");
        btnToggle.setLabel(StrUtil.formatMessage("@cwf.filetailer.btn.toggle.off.label"));
        isTailerStarted = true;
    }
}

From source file:com.sefford.fraggle.FraggleManager.java

/**
 * Process Clear backstack flag./*from w ww  . ja  v  a2 s. c o m*/
 * <p/>
 * FraggleManager will clear the back stack before trying to add the next Fragment if
 * {@link #CLEAR_BACKSTACK CLEAR_BACKSTACK} flag is found
 *
 * @param flags Added flags to the Fragment configuration
 */
protected void processClearBackstack(int flags) {
    if ((flags & CLEAR_BACKSTACK) == CLEAR_BACKSTACK) {
        try {
            fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        } catch (IllegalStateException exception) {
            log.e(TAG, exception.getMessage(), exception);
        }
    }
}

From source file:hr.fer.zemris.vhdllab.platform.manager.editor.impl.MultiInstanceEditorManager.java

@Override
public boolean save(boolean withDialog, SaveContext context) throws NotOpenedException {
    checkIfOpened();/*from www .j a v a  2 s. c o  m*/
    Validate.notNull(context, "Save context can't be null");
    if (identifier.getMetadata().isSaveable() && isModified()) {
        File file = editor.getFile();
        if (withDialog) {
            Project project = file.getProject();
            Boolean shouldContinue = dialogManager.showDialog(file.getName(), project.getName());
            if (!shouldContinue) {
                return false;
            }
        }
        try {
            workspaceManager.save(file);
            editor.setModified(false);
        } catch (IllegalStateException e) {
            if (file.getType().equals(FileType.SOURCE) && e.getMessage()
                    .equals("Resource " + file.getName() + " must have only one entity with the same name.")) {
                differentEntityNameDialogManager.showDialog();
                return false;
            }

            throw e;
        } catch (CircuitInterfaceExtractionException e) {
            if (file.getType().equals(FileType.SOURCE) && e.getMessage().equals("Entity block is invalid.")) {
                invalidEntityBlockDialogManager.showDialog();
                return false;
            }
            if (file.getType().equals(FileType.SOURCE) && e.getMessage().equals("Duplicate entity block")) {
                duplicateEntityBlockDialogManager.showDialog(file.getName());
                return false;
            }

            throw e;
        } catch (InvalidStateException e) {
            if (file.getType().equals(FileType.SOURCE)
                    && e.getMessage().startsWith("validation failed for: hr.fer.zemris.vhdllab.service.ci")) {
                invalidEntityBlockDialogManager.showDialog();
                return false;
            }

            throw e;
        }
    }
    return true;
}