Example usage for java.lang IllegalStateException printStackTrace

List of usage examples for java.lang IllegalStateException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.jogden.spunkycharts.traditionalchart.TraditionalChartFragmentAdapter.java

public void axisRefresh() {
    try {/*from  ww  w.  j  a  v a  2 s.c om*/
        _createPriceAxisY();
        _guiThrdHndlr.post(new Runnable() {
            public void run() {
                _timeAxis.invalidate();
                _volumeAxis.invalidate();
            }
        });
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }
}

From source file:com.aniruddhc.acemusic.player.NowPlayingActivity.NowPlayingActivity.java

/**
 * Initializes the current queue drawer/layout.
 *///from w  ww.j  a v a  2  s.c  o  m
private void initDrawer() {
    //Load the current queue drawer.
    mQueueDrawerFragment = new QueueDrawerFragment();

    try {
        getSupportFragmentManager().beginTransaction().replace(R.id.queue_drawer, mQueueDrawerFragment)
                .setCustomAnimations(R.anim.fade_in, R.anim.fade_out).commit();

    } catch (IllegalStateException e) {
        /*
         * Catches any exceptions that may occur if the
         * user rapidly changes the device's orientation.
         */
        e.printStackTrace();
    }

}

From source file:org.sonar.java.bytecode.se.BytecodeEGWalkerExecuteTest.java

private void tryCatch(boolean param) {
    try {/*from w w w . j av  a 2s  .c o m*/
        staticBooleanMethod();
        Preconditions.checkState(param);
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } finally {
        System.out.println("finally");
    }
}

From source file:com.gm.common.ui.widget.pageindicator.PageIndicatorView.java

private void unRegisterSetObserver() {
    if (setObserver != null && viewPager != null && viewPager.getAdapter() != null) {
        try {//from  www .  j  a  v a2 s  . com
            viewPager.getAdapter().unregisterDataSetObserver(setObserver);
            setObserver = null;
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.gm.common.ui.widget.pageindicator.PageIndicatorView.java

private void registerSetObserver() {
    if (setObserver == null && viewPager != null && viewPager.getAdapter() != null) {
        setObserver = new DataSetObserver() {
            @Override/*from  www  .ja v a 2  s . co  m*/
            public void onChanged() {
                if (viewPager != null && viewPager.getAdapter() != null) {

                    int newCount = viewPager.getAdapter().getCount();
                    int currItem = viewPager.getCurrentItem();

                    selectedPosition = currItem;
                    selectingPosition = currItem;
                    lastSelectedPosition = currItem;

                    endAnimation();
                    setCount(newCount);
                    setProgress(selectingPosition, 1.0f);
                }
            }
        };

        try {
            viewPager.getAdapter().registerDataSetObserver(setObserver);
        } catch (IllegalStateException e) {
            e.printStackTrace();
        }
    }
}

From source file:mp.teardrop.LibraryActivity.java

@Override
public void onResume() {
    super.onResume();

    /* Dropbox API stuff */
    AndroidAuthSession session = mApi.getSession();
    if (session.authenticationSuccessful()) {
        try {//from   w  w  w  . ja  v a 2  s .  c  o  m
            // Mandatory call to complete the auth
            session.finishAuthentication();

            // Store it locally in our app for later use
            storeAuth(session);
            updateUi(true);
        } catch (IllegalStateException e) {
            Toast.makeText(this, "Couldn't authenticate with Dropbox:" + e.getLocalizedMessage(),
                    Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }
    }
    /* end Dropbox API stuff */
}

From source file:edu.ku.brc.ui.tmanfe.SpreadSheet.java

/**
 * Paste data from clipboard into spreadsheet.
 * Currently only implemented for string data.
 *///  w  w w  .jav a  2  s.c o  m
public void paste() {
    //System.out.println("Trying to Paste");
    int[] rows = getSelectedRows();
    int[] cols = getSelectedColumns();
    pastedRows[0] = -1;
    pastedRows[1] = -1;
    if (rows != null && cols != null && rows.length > 0 && cols.length > 0) {
        int startRow = rows[0];
        pastedRows[0] = startRow;
        int startCol = cols[0];
        try {
            Clipboard sysClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
            if (sysClipboard.isDataFlavorAvailable(DataFlavor.stringFlavor)) {
                String trstring = (String) sysClipboard.getData(DataFlavor.stringFlavor);
                StringTokenizer st1 = new StringTokenizer(trstring, "\n\r");
                for (int i = 0; st1.hasMoreTokens(); i++) {
                    String rowstring = st1.nextToken();
                    //System.out.println("Row [" + rowstring+"]");
                    String[] tokens = StringUtils.splitPreserveAllTokens(rowstring, '\t');
                    for (int j = 0; j < tokens.length; j++) {
                        if (startRow + i < getRowCount() && startCol + j < getColumnCount()) {
                            int colInx = startCol + j;
                            if (tokens[j].length() <= model.getColDataLen(colInx)) {
                                String token = tokens[j];
                                if ("\b".equals(token)) //is placeholder for empty cell
                                {
                                    token = "";
                                }
                                setValueAt(token, startRow + i, colInx);
                            } else {
                                String msg = String.format(getResourceString("UI_NEWDATA_TOO_LONG"),
                                        new Object[] { model.getColumnName(startCol + j),
                                                model.getColDataLen(colInx) });
                                UIRegistry.getStatusBar().setErrorMessage(msg);
                                Toolkit.getDefaultToolkit().beep();
                            }
                        }
                        //System.out.println("Putting [" + tokens[j] + "] at row=" + startRow + i + "column=" + startCol + j);
                    }
                    pastedRows[1] = pastedRows[1] + 1;
                }
            }
        } catch (IllegalStateException ex) {
            UIRegistry.displayStatusBarErrMsg(getResourceString("Spreadsheet.ClipboardUnavailable"));
        } catch (Exception ex) {
            edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
            edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(SpreadSheet.class, ex);
            ex.printStackTrace();
        }
    }
}

From source file:com.inmobi.conduit.distcp.tools.mapred.TestCopyOutputFormat.java

@Test
public void testCheckOutputSpecs() {
    try {//from ww w . ja  va2 s.  com
        OutputFormat outputFormat = new CopyOutputFormat();
        Configuration conf = new Configuration();
        Job job = new Job(conf);
        JobID jobID = new JobID("200707121733", 1);

        try {
            JobContext context = Mockito.mock(JobContext.class);
            Mockito.when(context.getConfiguration()).thenReturn(job.getConfiguration());
            Mockito.when(context.getJobID()).thenReturn(jobID);
            outputFormat.checkOutputSpecs(context);
            Assert.fail("No checking for invalid work/commit path");
        } catch (IllegalStateException ignore) {
        }

        CopyOutputFormat.setWorkingDirectory(job, new Path("/tmp/work"));
        try {
            JobContext context = Mockito.mock(JobContext.class);
            Mockito.when(context.getConfiguration()).thenReturn(job.getConfiguration());
            Mockito.when(context.getJobID()).thenReturn(jobID);
            outputFormat.checkOutputSpecs(context);
            Assert.fail("No checking for invalid commit path");
        } catch (IllegalStateException ignore) {
        }

        job.getConfiguration().set(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH, "");
        CopyOutputFormat.setCommitDirectory(job, new Path("/tmp/commit"));
        try {
            JobContext context = Mockito.mock(JobContext.class);
            Mockito.when(context.getConfiguration()).thenReturn(job.getConfiguration());
            Mockito.when(context.getJobID()).thenReturn(jobID);
            outputFormat.checkOutputSpecs(context);
            Assert.fail("No checking for invalid work path");
        } catch (IllegalStateException ignore) {
        }

        CopyOutputFormat.setWorkingDirectory(job, new Path("/tmp/work"));
        CopyOutputFormat.setCommitDirectory(job, new Path("/tmp/commit"));
        try {
            JobContext context = Mockito.mock(JobContext.class);
            Mockito.when(context.getConfiguration()).thenReturn(job.getConfiguration());
            Mockito.when(context.getJobID()).thenReturn(jobID);
            outputFormat.checkOutputSpecs(context);
        } catch (IllegalStateException ignore) {
            ignore.printStackTrace();
            Assert.fail("Output spec check failed.");
        }

    } catch (IOException e) {
        LOG.error("Exception encountered while testing checkoutput specs", e);
        Assert.fail("Checkoutput Spec failure");
    } catch (InterruptedException e) {
        LOG.error("Exception encountered while testing checkoutput specs", e);
        Assert.fail("Checkoutput Spec failure");
    }
}

From source file:it.drwolf.ridire.session.JobManager.java

@Asynchronous
@Transactional//from   w w  w.ja  va2  s .  c  om
public String selectValidationResources(Integer jobId) {
    int transactionTimeoutSeconds = 600;
    this.userTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction");
    try {
        this.userTx.setTransactionTimeout(transactionTimeoutSeconds);
        // set timeout to
        // 10 mins
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        Job j = this.entityManager.find(Job.class, jobId);
        j.setValidationStatus(Job.VALIDATION_WAIT);
        this.entityManager.persist(j);
        this.entityManager.flush();
        this.userTx.commit();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        Number resourcesWordsNumberAverage = (Number) this.entityManager
                .createQuery("select avg(cr.wordsNumber) from CrawledResource cr where cr.job=:j")
                .setParameter("j", j).getSingleResult();
        double percent = 0.0;
        if (resourcesWordsNumberAverage.doubleValue() < 100.0) {
            percent = 0.01;
        } else if (resourcesWordsNumberAverage.doubleValue() > 99100.0) {
            percent = 1;
        } else {
            percent = resourcesWordsNumberAverage.doubleValue() / 1000 + 0.9;
        }
        percent = percent / 100;
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        Map<String, Number> jobValidationData = this.getJobValidationDataForJob(j, this.entityManager);
        this.entityManager.flush();
        this.userTx.commit();
        int n0_100 = new Double(Math.ceil(jobValidationData.get("nd-res0-100").doubleValue() * percent))
                .intValue();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        this.selectResourceToBeValidated(n0_100, 0, 100, this.entityManager, j);
        this.entityManager.flush();
        this.userTx.commit();
        int n101_1000 = new Double(Math.ceil(jobValidationData.get("nd-res101-1000").doubleValue() * percent))
                .intValue();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        this.selectResourceToBeValidated(n101_1000, 101, 1000, this.entityManager, j);
        this.entityManager.flush();
        this.userTx.commit();
        int n1001_5000 = new Double(Math.ceil(jobValidationData.get("nd-res1001-5000").doubleValue() * percent))
                .intValue();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        this.selectResourceToBeValidated(n1001_5000, 1001, 5000, this.entityManager, j);
        this.entityManager.flush();
        this.userTx.commit();
        int n5001_10000 = new Double(
                Math.ceil(jobValidationData.get("nd-res5001-10000").doubleValue() * percent)).intValue();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        this.selectResourceToBeValidated(n5001_10000, 5001, 10000, this.entityManager, j);
        this.entityManager.flush();
        this.userTx.commit();
        int n10000 = new Double(Math.ceil(jobValidationData.get("nd-res10000+").doubleValue() * percent))
                .intValue();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        this.entityManager.joinTransaction();
        this.selectResourceToBeValidated(n10000, 10001, Integer.MAX_VALUE, this.entityManager, j);
        this.entityManager.flush();
        this.userTx.commit();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
        j.setValidationStatus(Job.VALIDATION_IN_PROGRESS);
        this.entityManager.joinTransaction();
        this.entityManager.merge(j);
        this.entityManager.flush();
        this.userTx.commit();
        if (!this.userTx.isActive()) {
            this.userTx.begin();
        }
    } catch (Exception e) {
        try {
            if (this.userTx != null && this.userTx.isActive()) {
                this.userTx.rollback();
            }
        } catch (IllegalStateException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SecurityException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (SystemException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
        e.printStackTrace();
    } finally {

    }
    return "OK";
}

From source file:org.kuali.rice.kew.server.WorkflowUtilityTest.java

private void runTestPerformDocumentSearch_RouteNodeSearch(String principalId) throws Exception {
    String documentTypeName = SeqSetup.DOCUMENT_TYPE_NAME;
    setupPerformDocumentSearchTests(documentTypeName, SeqSetup.WORKFLOW_DOCUMENT_NODE, "Doc Title");

    // test exception thrown when route node specified and no doc type specified
    DocumentSearchCriteria.Builder criteria = DocumentSearchCriteria.Builder.create();
    criteria.setRouteNodeName(SeqSetup.ADHOC_NODE);
    try {//from ww w.  ja v  a 2 s .com
        KewApiServiceLocator.getWorkflowDocumentService().documentSearch(principalId, criteria.build());
        fail("Exception should have been thrown when specifying a route node name but no document type name");
    } catch (IllegalStateException e) {
        e.printStackTrace();
    }

    // test exception thrown when route node specified does not exist on document type
    criteria = DocumentSearchCriteria.Builder.create();
    criteria.setDocumentTypeName(documentTypeName);
    criteria.setRouteNodeName("This is an invalid route node name!!!");
    try {
        DocumentSearchResults results = KewApiServiceLocator.getWorkflowDocumentService()
                .documentSearch(principalId, criteria.build());
        assertTrue(
                "No results should have been returned for route node name that does not exist on the specified documentType.",
                results.getSearchResults().isEmpty());
    } catch (Exception e) {
        fail("Exception should not have been thrown when specifying a route node name that does not exist on the specified document type name");
    }

    runPerformDocumentSearch_RouteNodeSearch(principalId, SeqSetup.ADHOC_NODE, documentTypeName, 0, 0, 2);
    runPerformDocumentSearch_RouteNodeSearch(principalId, SeqSetup.WORKFLOW_DOCUMENT_NODE, documentTypeName, 0,
            2, 0);
    runPerformDocumentSearch_RouteNodeSearch(principalId, SeqSetup.WORKFLOW_DOCUMENT_2_NODE, documentTypeName,
            2, 0, 0);
}