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:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized Serializable locPut(final String key, final Serializable value) {
    Serializable result = null;/*  w  ww .jav a  2s.c om*/
    try {
        openFile();
        read();
        result = properties.put(key, value);
        write();
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized Object remove(final String key) {
    Object result = null;//from  w w w  .j  av  a2  s.  com
    try {
        openFile();
        read();
        result = properties.remove(key);
        write();
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
    }
    closeFile();
    return result;
}

From source file:com.cedarsoftware.ncube.NCubeManager.java

/**
 * This API creates a SNAPSHOT set of cubes by copying all of
 * the RELEASE ncubes that match the oldVersion and app to
 * the new version in SNAPSHOT mode.  Basically, it duplicates
 * an entire set of NCubes and places a new version label on them,
 * in SNAPSHOT status.//  w  w  w.  j  a  v a 2  s. c  o m
 */
public static int createSnapshotCubes(Connection connection, String app, String relVersion, String newSnapVer) {
    validate(connection, app, relVersion);
    validateVersion(newSnapVer);

    if (relVersion.equals(newSnapVer)) {
        throw new IllegalArgumentException(
                "New SNAPSHOT version " + relVersion + " cannot be the same as the RELEASE version.");
    }

    synchronized (cubeList) {
        PreparedStatement stmt0 = null;
        PreparedStatement stmt1 = null;
        PreparedStatement stmt2 = null;

        try {
            stmt0 = connection
                    .prepareStatement("SELECT n_cube_id FROM n_cube WHERE app_cd = ? AND version_no_cd = ?");
            stmt0.setString(1, app);
            stmt0.setString(2, newSnapVer);
            ResultSet rs = stmt0.executeQuery();
            if (rs.next()) {
                throw new IllegalStateException("New SNAPSHOT Version specified (" + newSnapVer
                        + ") matches an existing version.  Specify new SNAPSHOT version that does not exist.");
            }
            rs.close();

            stmt1 = connection.prepareStatement(
                    "SELECT n_cube_nm, cube_value_bin, create_dt, update_dt, create_hid, update_hid, version_no_cd, status_cd, sys_effective_dt, sys_expiration_dt, business_effective_dt, business_expiration_dt, app_cd, test_data_bin, notes_bin\n"
                            + "FROM n_cube\n" + "WHERE app_cd = ? AND version_no_cd = ? AND status_cd = '"
                            + ReleaseStatus.RELEASE + "'");

            stmt1.setString(1, app);
            stmt1.setString(2, relVersion);
            rs = stmt1.executeQuery();

            stmt2 = connection.prepareStatement(
                    "INSERT INTO n_cube (n_cube_id, n_cube_nm, cube_value_bin, create_dt, update_dt, create_hid, update_hid, version_no_cd, status_cd, sys_effective_dt, sys_expiration_dt, business_effective_dt, business_expiration_dt, app_cd, test_data_bin, notes_bin)\n"
                            + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
            int count = 0;

            while (rs.next()) {
                count++;
                stmt2.setLong(1, UniqueIdGenerator.getUniqueId());
                stmt2.setString(2, rs.getString("n_cube_nm"));
                stmt2.setBytes(3, rs.getBytes("cube_value_bin"));
                stmt2.setDate(4, new java.sql.Date(System.currentTimeMillis()));
                stmt2.setDate(5, new java.sql.Date(System.currentTimeMillis()));
                stmt2.setString(6, rs.getString("create_hid"));
                stmt2.setString(7, rs.getString("update_hid"));
                stmt2.setString(8, newSnapVer);
                stmt2.setString(9, ReleaseStatus.SNAPSHOT.name());
                stmt2.setDate(10, rs.getDate("sys_effective_dt"));
                stmt2.setDate(11, rs.getDate("sys_expiration_dt"));
                stmt2.setDate(12, rs.getDate("business_effective_dt"));
                stmt2.setDate(13, rs.getDate("business_expiration_dt"));
                stmt2.setString(14, rs.getString("app_cd"));
                stmt2.setBytes(15, rs.getBytes("test_data_bin"));
                stmt2.setBytes(16, rs.getBytes("notes_bin"));
                stmt2.executeUpdate();
            }
            return count;
        } catch (IllegalStateException e) {
            throw e;
        } catch (Exception e) {
            String s = "Unable to create SNAPSHOT NCubes for app: " + app + ", version: " + newSnapVer
                    + ", due to an error: " + e.getMessage();
            LOG.error(s, e);
            throw new RuntimeException(s, e);
        } finally {
            jdbcCleanup(stmt0);
            jdbcCleanup(stmt1);
            jdbcCleanup(stmt2);
        }
    }
}

From source file:com.almende.eve.state.file.ConcurrentSerializableFileState.java

@Override
public synchronized boolean locPutIfUnchanged(final String key, final Serializable newVal,
        final Serializable oldVal) {
    boolean result = false;
    try {//from  ww  w . j a v a2s  .c o m
        openFile();
        read();
        if (!(oldVal == null && properties.containsKey(key) && properties.get(key) != null)
                || (properties.get(key) != null && properties.get(key).equals(oldVal))) {
            properties.put(key, newVal);
            write();
            result = true;
        }
    } catch (final IllegalStateException e) {
        LOG.log(Level.WARNING, "Statefile is missing: " + e.getMessage());
    } catch (final Exception e) {
        LOG.log(Level.WARNING, "", e);
        // Don't let users loop if exception is thrown. They
        // would get into a deadlock....
        result = true;
    }
    closeFile();
    return result;
}

From source file:org.csanchez.jenkins.plugins.kubernetes.pipeline.ContainerExecDecorator.java

@Override
public void close() throws IOException {
    if (watch != null) {
        try {/*from   ww w . j av a  2 s. c om*/
            watch.close();
        } catch (IllegalStateException e) {
            LOGGER.log(Level.INFO, "Watch was already closed: {0}", e.getMessage());
        } catch (Exception e) {
            LOGGER.log(Level.WARNING, "Error closing watch", e);
        } finally {
            watch = null;
        }
    }

    if (proc != null) {
        try {
            proc.kill();
        } catch (InterruptedException e) {
            throw new InterruptedIOException();
        }
    }
}

From source file:org.simbrain.plot.histogram.HistogramPanel.java

/**
 * Create the histogram panel based on the data.
 *//*from   ww w .j  a va2s  . c  om*/
public void createHistogram() {
    try {
        if (this.getModel().getData() != null) {
            mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(),
                    PlotOrientation.VERTICAL, true, true, false);
            mainChart.setBackgroundPaint(UIManager.getColor("this.Background"));

            XYPlot plot = (XYPlot) mainChart.getPlot();
            plot.setForegroundAlpha(0.75F);
            // Sets y-axis ticks to integers.
            NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
            renderer.setDrawBarOutline(false);
            renderer.setShadowVisible(false);

            Iterator<ColoredDataSeries> series = model.getSeriesData().iterator();
            for (int i = 0; i < model.getData().size(); i++) {
                if (i < colorPallet.length) {
                    ColoredDataSeries s = series.next();
                    Color c = s.color;
                    if (c == null) {
                        c = assignColor();
                        s.color = c;
                    }
                    renderer.setSeriesPaint(i, c, true);
                }
            }

        } else {

            mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(),
                    PlotOrientation.VERTICAL, true, true, false);
            mainChart.setBackgroundPaint(UIManager.getColor("this.Background"));

        }

    } catch (IllegalArgumentException iaEx) {
        iaEx.printStackTrace();
        JOptionPane.showMessageDialog(null, iaEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    } catch (IllegalStateException isEx) {
        isEx.printStackTrace();
        JOptionPane.showMessageDialog(null, isEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
    }
    mainPanel = new ChartPanel(mainChart);

}

From source file:com.blackducksoftware.integration.hub.bamboo.tasks.HubScanTask.java

private HubScanConfig getScanConfig(final ConfigurationMap configMap, final File workingDirectory,
        final File toolsDir, final String thirdPartyVersion, final String pluginVersion, final IntLogger logger)
        throws IOException {
    try {/*from   w ww.ja v  a  2s .c  o m*/
        final String project = configMap.get(HubScanConfigFieldEnum.PROJECT.getKey());
        final String version = configMap.get(HubScanConfigFieldEnum.VERSION.getKey());
        final String phase = configMap.get(HubScanConfigFieldEnum.PHASE.getKey());
        final String distribution = configMap.get(HubScanConfigFieldEnum.DISTRIBUTION.getKey());

        final String dryRun = configMap.get(HubScanConfigFieldEnum.DRY_RUN.getKey());
        final String cleanupLogsOnSuccess = configMap
                .get(HubScanConfigFieldEnum.CLEANUP_LOGS_ON_SUCCESS.getKey());

        final String excludePatternsConfig = configMap.get(HubScanConfigFieldEnum.EXCLUDE_PATTERNS.getKey());

        final String[] excludePatterns = HubBambooUtils.getInstance()
                .createExcludePatterns(excludePatternsConfig);

        final String scanMemory = configMap.get(HubScanConfigFieldEnum.SCANMEMORY.getKey());
        final String codeLocationName = configMap.get(HubScanConfigFieldEnum.CODE_LOCATION_ALIAS.getKey());
        final String targets = configMap.get(HubScanConfigFieldEnum.TARGETS.getKey());

        final String hubWorkspaceCheckString = getPersistedValue(HubConfigKeys.CONFIG_HUB_WORKSPACE_CHECK);

        Boolean hubWorkspaceCheck = true;
        if (StringUtils.isNotBlank(hubWorkspaceCheckString)) {
            hubWorkspaceCheck = Boolean.valueOf(hubWorkspaceCheckString);
        }

        final List<String> scanTargets = HubBambooUtils.getInstance().createScanTargetPaths(targets,
                workingDirectory);

        if (scanTargets.isEmpty()) {
            // no targets specified assume the working directory.
            scanTargets.add(workingDirectory.getCanonicalPath());
        }

        final HubScanConfigBuilder hubScanConfigBuilder = new HubScanConfigBuilder();
        hubScanConfigBuilder.setProjectName(project);
        hubScanConfigBuilder.setVersion(version);
        hubScanConfigBuilder.setPhase(PhaseEnum.getPhaseByDisplayValue(phase).name());
        hubScanConfigBuilder
                .setDistribution(DistributionEnum.getDistributionByDisplayValue(distribution).name());
        hubScanConfigBuilder.setWorkingDirectory(workingDirectory);
        hubScanConfigBuilder.setDryRun(Boolean.valueOf(dryRun));
        hubScanConfigBuilder.setCleanupLogsOnSuccess(Boolean.valueOf(cleanupLogsOnSuccess));
        hubScanConfigBuilder.setScanMemory(scanMemory);
        hubScanConfigBuilder.addAllScanTargetPaths(scanTargets);
        hubScanConfigBuilder.setExcludePatterns(excludePatterns);
        hubScanConfigBuilder.setToolsDir(toolsDir);
        hubScanConfigBuilder.setThirdPartyName(ThirdPartyName.BAMBOO);
        hubScanConfigBuilder.setThirdPartyVersion(thirdPartyVersion);
        hubScanConfigBuilder.setPluginVersion(pluginVersion);
        hubScanConfigBuilder.setCodeLocationAlias(codeLocationName);
        if (hubWorkspaceCheck) {
            hubScanConfigBuilder.enableScanTargetPathsWithinWorkingDirectoryCheck();
        }
        return hubScanConfigBuilder.build();
    } catch (final IllegalStateException e) {
        logger.error(e.getMessage());
        logger.debug("", e);
    }
    return null;
}

From source file:org.apache.geode.management.internal.cli.commands.DestroyRegionCommand.java

@CliCommand(value = { CliStrings.DESTROY_REGION }, help = CliStrings.DESTROY_REGION__HELP)
@CliMetaData(relatedTopic = CliStrings.TOPIC_GEODE_REGION)
@ResourceOperation(resource = ResourcePermission.Resource.DATA, operation = ResourcePermission.Operation.MANAGE)
public Result destroyRegion(
        @CliOption(key = CliStrings.DESTROY_REGION__REGION, optionContext = ConverterHint.REGION_PATH, mandatory = true, help = CliStrings.DESTROY_REGION__REGION__HELP) String regionPath) {

    if (regionPath == null) {
        return ResultBuilder.createInfoResult(CliStrings.DESTROY_REGION__MSG__SPECIFY_REGIONPATH_TO_DESTROY);
    }//  www  . j  a v a2 s. c om

    if (StringUtils.isBlank(regionPath) || regionPath.equals(Region.SEPARATOR)) {
        return ResultBuilder.createInfoResult(CliStrings
                .format(CliStrings.DESTROY_REGION__MSG__REGIONPATH_0_NOT_VALID, new Object[] { regionPath }));
    }

    Result result;
    AtomicReference<XmlEntity> xmlEntity = new AtomicReference<>();
    try {
        InternalCache cache = getCache();
        ManagementService managementService = ManagementService.getExistingManagementService(cache);
        String regionPathToUse = regionPath;

        if (!regionPathToUse.startsWith(Region.SEPARATOR)) {
            regionPathToUse = Region.SEPARATOR + regionPathToUse;
        }

        Set<DistributedMember> regionMembersList = findMembersForRegion(cache, managementService,
                regionPathToUse);

        if (regionMembersList.size() == 0) {
            return ResultBuilder.createUserErrorResult(
                    CliStrings.format(CliStrings.DESTROY_REGION__MSG__COULD_NOT_FIND_REGIONPATH_0_IN_GEODE,
                            regionPath, "jmx-manager-update-rate milliseconds"));
        }

        CliFunctionResult destroyRegionResult;

        ResultCollector<?, ?> resultCollector = CliUtil.executeFunction(RegionDestroyFunction.INSTANCE,
                regionPath, regionMembersList);
        List<CliFunctionResult> resultsList = (List<CliFunctionResult>) resultCollector.getResult();
        String message = CliStrings.format(CliStrings.DESTROY_REGION__MSG__REGION_0_1_DESTROYED, regionPath,
                "");

        // Only if there is an error is this set to false
        boolean isRegionDestroyed = true;
        for (CliFunctionResult aResultsList : resultsList) {
            destroyRegionResult = aResultsList;
            if (destroyRegionResult.isSuccessful()) {
                xmlEntity.set(destroyRegionResult.getXmlEntity());
            } else if (destroyRegionResult.getThrowable() != null) {
                Throwable t = destroyRegionResult.getThrowable();
                LogWrapper.getInstance().info(t.getMessage(), t);
                message = CliStrings.format(
                        CliStrings.DESTROY_REGION__MSG__ERROR_OCCURRED_WHILE_DESTROYING_0_REASON_1, regionPath,
                        t.getMessage());
                isRegionDestroyed = false;
            } else {
                message = CliStrings.format(
                        CliStrings.DESTROY_REGION__MSG__UNKNOWN_RESULT_WHILE_DESTROYING_REGION_0_REASON_1,
                        regionPath, destroyRegionResult.getMessage());
                isRegionDestroyed = false;
            }
        }
        if (isRegionDestroyed) {
            result = ResultBuilder.createInfoResult(message);
        } else {
            result = ResultBuilder.createUserErrorResult(message);
        }
    } catch (IllegalStateException e) {
        result = ResultBuilder.createUserErrorResult(
                CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1,
                        regionPath, e.getMessage()));
    } catch (Exception e) {
        result = ResultBuilder.createGemFireErrorResult(
                CliStrings.format(CliStrings.DESTROY_REGION__MSG__ERROR_WHILE_DESTROYING_REGION_0_REASON_1,
                        regionPath, e.getMessage()));
    }

    if (xmlEntity.get() != null) {
        persistClusterConfiguration(result,
                () -> getSharedConfiguration().deleteXmlEntity(xmlEntity.get(), null));
    }

    return result;
}

From source file:com.meltmedia.cadmium.servlets.jersey.StatusService.java

@GET
@Produces(MediaType.APPLICATION_JSON)/*w w  w. j a  v a 2s  .c  o m*/
public Status status(@HeaderParam("Authorization") @DefaultValue("no token") String auth) throws Exception {
    boolean authorized = false;
    try {
        if (this.isAuth(auth)) {
            authorized = true;
        }
    } catch (Throwable t) {
        logger.warn("Authentication failed for status: " + auth, t);
    }
    Status returnObj = new Status();
    String rev = null;
    String branch = null;
    String repo = null;
    String configRev = null;
    String configBranch = null;
    String configRepo = null;

    Properties configProperties = configManager.getDefaultProperties();

    // Get content directory
    String contentDir = configProperties.getProperty("com.meltmedia.cadmium.lastUpdated", "");
    // Get config directory
    String configDir = configProperties.getProperty("com.meltmedia.cadmium.config.lastUpdated", "");

    GitService git = null;
    try {
        git = gitService.getGitServiceNoBlock();
        rev = git.getCurrentRevision();
        branch = git.getBranchName();
        repo = git.getRemoteRepository();
    } catch (IllegalStateException e) {
        logger.debug("Content git service is not yet set: " + e.getMessage());
    } finally {
        try {
            gitService.releaseGitService();
        } catch (IllegalMonitorStateException e) {
            logger.debug("Released unattained read lock.");
        }
    }

    // Get cadmium project info (branch, repo and revision)
    rev = configProperties.getProperty("git.ref.sha", rev);
    branch = configProperties.getProperty("branch",
            branch == null ? configProperties.getProperty("com.meltmedia.cadmium.branch") : branch);
    repo = configProperties.getProperty("repo",
            repo == null ? configProperties.getProperty("com.meltmedia.cadmium.git.uri") : repo);

    git = null;
    try {
        git = configGitService.getGitServiceNoBlock();
        configRev = git.getCurrentRevision();
        configBranch = git.getBranchName();
        configRepo = git.getRemoteRepository();
    } catch (IllegalStateException e) {
        logger.debug("Config git service is not yet set: " + e.getMessage());
    } finally {
        try {
            configGitService.releaseGitService();
        } catch (IllegalMonitorStateException e) {
            logger.debug("Released unattained read lock.");
        }
    }

    // Get cadmium project info (branch, repo and revision)
    configRev = configProperties.getProperty("config.git.ref.sha", configRev);
    configBranch = configProperties.getProperty("config.branch",
            configBranch == null ? configProperties.getProperty("com.meltmedia.cadmium.config.branch")
                    : configBranch);
    configRepo = configProperties.getProperty("config.repo",
            configRepo == null ? configProperties.getProperty("com.meltmedia.cadmium.config.git.uri", repo)
                    : configRepo);

    // Get source project info (branch, repo and revision)
    String sourceFile = contentDir + File.separator + "META-INF" + File.separator + "source";
    String source = "{}";
    if (FileSystemManager.canRead(sourceFile)) {
        source = FileSystemManager.getFileContents(sourceFile);
    } else {
        logger.trace("No source file [{}]", sourceFile);
    }
    logger.trace("Source [{}] is from [{}]", source, sourceFile);

    if (authorized) {
        // Get cluster members' status
        List<ChannelMember> members = lifecycleService.getPeirStates();

        if (members != null) {

            List<StatusMember> peers = new ArrayList<StatusMember>();

            for (ChannelMember member : members) {

                StatusMember peer = new StatusMember();
                peer.setAddress(member.getAddress().toString());
                peer.setCoordinator(member.isCoordinator());
                peer.setState(member.getState());
                peer.setConfigState(member.getConfigState());
                peer.setMine(member.isMine());
                peer.setExternalIp(member.getExternalIp());
                peer.setWarInfo(member.getWarInfo());
                peers.add(peer);

            }

            returnObj.setMembers(peers);
        }
        returnObj.setContentDir(contentDir);
        returnObj.setConfigDir(configDir);
        returnObj.setRepo(repo);
        returnObj.setConfigRepo(configRepo);

        InputStream in = null;
        try {
            in = getClass().getClassLoader().getResourceAsStream("cadmium-version.properties");
            Properties props = new Properties();
            props.load(in);
            if (props.containsKey("version")) {
                returnObj.setCadmiumVersion(props.getProperty("version"));
            }
        } catch (Throwable t) {
            logger.debug("Failed to get cadmium version.", t);
        } finally {
            if (in != null) {
                IOUtils.closeQuietly(in);
            }
        }
    }

    // Get environment status 
    String environFromConfig = System.getProperty("com.meltmedia.cadmium.environment");

    if (environFromConfig != null && environFromConfig.trim().length() > 0) {

        returnObj.setEnvironment(environFromConfig);

    } else {

        returnObj.setEnvironment(ENVIRON_DEV);
    }

    // Get Maintanence page status (on or off)
    String maintStatus;
    if (maintService.isOn()) {

        maintStatus = MAINT_ON;
    } else {

        maintStatus = MAINT_OFF;
    }

    returnObj.setGroupName(sender.getGroupName());
    returnObj.setBranch(branch);
    returnObj.setRevision(rev);
    returnObj.setConfigBranch(configBranch);
    returnObj.setConfigRevision(configRev);
    returnObj.setMaintPageState(maintStatus);
    returnObj.setSource(source);

    return returnObj;
}

From source file:org.eurekastreams.commons.server.ExceptionSanitizerTest.java

/**
 * Tests how exceptions are returned to client.
 *//*from   w ww.jav a 2  s  .  c  om*/
@Test
public void testOtherExceptionNested() {
    final IllegalStateException exCause = new IllegalStateException("really bad");
    Exception exIn = new IllegalArgumentException(exCause);
    Exception exOut = coreForbidNestingExceptionTest(exIn);
    assertTrue(exOut instanceof GeneralException);
    assertTrue(!exIn.getMessage().equals(exOut.getMessage()));
    assertTrue(!exCause.getMessage().equals(exOut.getMessage()));
}