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.resthub.rpc.java.SpringAMQPProxyTest.java

@Test(groups = "java-serialization")
public void testSerializationError() throws Exception {
    try {/* ww w  .  j a va  2 s.  co m*/
        serializationError.getNotSerializable();
        fail("IllegalStateException expected");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("must implement java.io.Serializable"));
    }
}

From source file:org.resthub.rpc.SpringAMQPHessianProxyTest.java

@Test
public void testSerializationError() throws Exception {
    try {//from   www.  j  a  v  a2s .co m
        serializationError.getNotSerializable();
        fail("IllegalStateException expected");
    } catch (IllegalStateException e) {
        assertTrue(e.getMessage().contains("must implement java.io.Serializable"));
    }
}

From source file:org.alfresco.repo.web.scripts.TenantWebScriptServlet.java

protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    if (logger.isDebugEnabled())
        logger.debug("Processing tenant request (" + req.getMethod() + ") " + req.getRequestURL()
                + (req.getQueryString() != null ? "?" + req.getQueryString() : ""));

    if (req.getCharacterEncoding() == null) {
        req.setCharacterEncoding("UTF-8");
    }// w  ww.  j a  v a  2 s  . c  o  m

    setLanguageFromRequestHeader(req);

    try {
        WebScriptServletRuntime runtime = getRuntime(req, res);
        runtime.executeScript();
    } catch (IllegalStateException e) {
        if (e.getMessage().contains("getOutputStream() has already been called for this response")) {
            if (logger.isDebugEnabled()) {
                logger.warn("Client has cut off communication", e);
            } else {
                logger.warn("Client has cut off communication");
            }
        } else {
            throw e;
        }
    } finally {
        // clear threadlocal
        I18NUtil.setLocale(null);
        // clear authentication and tenant context
        AuthenticationUtil.clearCurrentSecurityContext();
    }
}

From source file:org.apache.hive.hcatalog.templeton.StatusDelegator.java

public QueueStatusBean run(String user, String id)
        throws NotAuthorizedException, BadParam, IOException, InterruptedException {
    WebHCatJTShim tracker = null;/*  w  w w .j  a  v a  2  s  .  c om*/
    JobState state = null;
    try {
        UserGroupInformation ugi = UgiFactory.getUgi(user);
        tracker = ShimLoader.getHadoopShims().getWebHCatShim(appConf, ugi);
        JobID jobid = StatusDelegator.StringToJobID(id);
        if (jobid == null)
            throw new BadParam("Invalid jobid: " + id);
        state = new JobState(id, Main.getAppConfigInstance());
        return StatusDelegator.makeStatus(tracker, jobid, state);
    } catch (IllegalStateException e) {
        throw new BadParam(e.getMessage());
    } finally {
        if (tracker != null)
            tracker.close();
        if (state != null)
            state.close();
    }
}

From source file:ch.wisv.areafiftylan.exception.GlobalControllerExceptionHandler.java

@ExceptionHandler(IllegalStateException.class)
public ResponseEntity<?> handleIllegalStateException(IllegalStateException ex) {
    return createResponseEntity(HttpStatus.BAD_REQUEST, ex.getMessage());
}

From source file:de.willert.crucible.extendedapi.RestResolutionStatusService.java

/**
 * Gets comment resolution data.// w  w w. ja  v  a 2  s . c  o  m
 * <p>
 * comments/{cId}/resolutionStatus
 * <p>
 * {@link com.atlassian.crucible.spi.data.CommentResolutionData}
 * {@link com.atlassian.crucible.spi.data.CommentResolutionStatus}
 *
 * @param cId The comment Id
 * @return Comment Resolution
 */
@GET
@Path("{cId}/resolutionStatus")
public Response resolutionStatus(@PathParam("cId") String cId) {
    final PermId<CommentData> commentPermId;

    if (cId.isEmpty() || !NumberUtils.isNumber(cId)) {
        return Response.status(Response.Status.BAD_REQUEST).entity(ERROR_ID_INVALID).build();
    }

    commentPermId = new PermId<>(cId);

    try {
        final com.atlassian.crucible.spi.data.CommentResolutionData commentResolution = reviewService
                .getCommentResolution(commentPermId);
        final CommentResolutionData commentResolutionData = new CommentResolutionData(commentResolution);
        return Response.ok().entity(commentResolutionData).build();
    } catch (NotFoundException nfe) {
        return Response.status(Response.Status.NOT_FOUND).entity(ERROR_ID_NOT_FOUND).build();
    } catch (NotPermittedException npe) {
        return Response.status(Response.Status.UNAUTHORIZED).entity(ERROR_NOT_PERMITTED).build();
    } catch (IllegalStateException ise) {
        return Response.serverError().entity(ise.getMessage()).build();
    }
}

From source file:io.github.seleniumquery.browser.driver.builders.ChromeDriverBuilder.java

private void throwCustomExceptionIfExecutableWasNotFound(IllegalStateException e) {
    if (e.getMessage().contains("path to the driver executable must be set")) {
        throw new SeleniumQueryException(format(
                "The ChromeDriver server executable (%s/%s) was not found in the classpath, in the \"%s\" system property or in the system's PATH variable. %s",
                CHROMEDRIVER_EXECUTABLE_WINDOWS, CHROMEDRIVER_EXECUTABLE_LINUX,
                CHROME_DRIVER_EXECUTABLE_SYSTEM_PROPERTY, EXCEPTION_MESSAGE), e);
    }//from ww  w  .  j a  v a2 s . co m
}

From source file:org.apache.hcatalog.templeton.StatusDelegator.java

public QueueStatusBean run(String user, String id)
        throws NotAuthorizedException, BadParam, IOException, InterruptedException {
    TempletonJobTracker tracker = null;//ww  w.  j  a  v  a2  s  .co m
    JobState state = null;
    try {
        tracker = new TempletonJobTracker(appConf);
        JobID jobid = StatusDelegator.StringToJobID(id);
        if (jobid == null)
            throw new BadParam("Invalid jobid: " + id);
        state = new JobState(id, Main.getAppConfigInstance());
        return StatusDelegator.makeStatus(tracker, jobid, state);
    } catch (IllegalStateException e) {
        throw new BadParam(e.getMessage());
    } finally {
        if (tracker != null)
            tracker.close();
        if (state != null)
            state.close();
    }
}

From source file:com.sap.prd.mobile.ios.ota.webapp.BaseServlet.java

/**
 * Returns an unmodifiable map containing all init parameters. 
 * @return/*from w  w w.java 2s. c o  m*/
 */
protected Map<String, String> getInitParameters() {
    HashMap<String, String> map = new HashMap<String, String>();
    try {
        Enumeration<String> initParameterNames = this.getServletContext().getInitParameterNames();
        while (initParameterNames.hasMoreElements()) {
            String name = initParameterNames.nextElement();
            map.put(name, this.getServletContext().getInitParameter(name));
        }
    } catch (IllegalStateException e) {
        if (!e.getMessage().equals("ServletConfig has not been initialized"))
            throw e;
    }
    return Collections.unmodifiableMap(map);
}

From source file:org.keycloak.testsuite.util.TestEventsLogger.java

private void createPageSrcFile(Description d) throws IOException {
    try {//  w w  w  . jav a  2  s . co m
        if (driver != null && driver.getPageSource() != null) {
            String pageSourceLocation = System.getProperty("page.source.location",
                    "target/failed-tests/page-source/");
            FileUtils.writeStringToFile(new File(
                    pageSourceLocation + d.getTestClass().getSimpleName() + "/" + d.getMethodName() + ".html"),
                    driver.getPageSource(), Charset.forName("UTF-8"));
        }
    } catch (IllegalStateException ex) {
        Logger.getLogger(TestEventsLogger.class).warn(ex.getMessage());
    }
}