List of usage examples for java.lang RuntimeException getMessage
public String getMessage()
From source file:com.uber.stream.kafka.mirrormaker.manager.TestManagerConf.java
@Test public void testDefaultCmdControllerConf() throws ParseException { try {/* w w w . ja va2 s. com*/ String[] args = new String[] {}; CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); ManagerConf conf = ManagerConf.getManagerConf(cmd); Assert.fail("Expected exception to be thrown"); } catch (RuntimeException e) { Assert.assertTrue(e.getMessage().equals("Missing option: --zookeeper")); } try { String[] args = new String[] { "-zookeeper", "localhost:2181/test" }; CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); ManagerConf conf = ManagerConf.getManagerConf(cmd); Assert.fail("Expected exception to be thrown"); } catch (RuntimeException e) { Assert.assertTrue(e.getMessage().equals("Missing option: --managerPort")); } try { String[] args = new String[] { "-zookeeper", "localhost:2181/test", "-managerPort", "9090" }; CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); ManagerConf conf = ManagerConf.getManagerConf(cmd); Assert.fail("Expected exception to be thrown"); } catch (RuntimeException e) { Assert.assertTrue(e.getMessage().equals("Missing option: --deployment")); } try { String[] args = new String[] { "-zookeeper", "localhost:2181/test", "-managerPort", "9090", "-deployment", "testing" }; CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); ManagerConf conf = ManagerConf.getManagerConf(cmd); Assert.fail("Expected exception to be thrown"); } catch (RuntimeException e) { Assert.assertTrue(e.getMessage().equals("Missing option: --env")); } try { String[] args = new String[] { "-zookeeper", "localhost:2181/test", "-managerPort", "9090", "-deployment", "testing", "-env", "dc.testing" }; CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); ManagerConf conf = ManagerConf.getManagerConf(cmd); Assert.fail("Expected exception to be thrown"); } catch (RuntimeException e) { Assert.assertTrue(e.getMessage().equals("Missing option: --controllerPort")); } try { String[] args = new String[] { "-zookeeper", "localhost:2181/test", "-managerPort", "9090", "-deployment", "testing", "-controllerPort", "8080", "-env", "dc.testing" }; CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(ManagerConf.constructManagerOptions(), args); ManagerConf conf = ManagerConf.getManagerConf(cmd); Assert.assertTrue(conf.getSourceClusters().isEmpty()); Assert.assertTrue(conf.getDestinationClusters().isEmpty()); Assert.assertEquals(conf.getManagerZkStr(), "localhost:2181/test"); Assert.assertEquals(conf.getManagerPort().toString(), "9090"); Assert.assertEquals(conf.getManagerDeployment(), "testing"); Assert.assertEquals(conf.getManagerInstanceId(), InetAddress.getLocalHost().getHostName()); Assert.assertEquals(conf.getControllerPort().toString(), "8080"); Assert.assertEquals(conf.getC3Host(), "localhost"); Assert.assertEquals(conf.getC3Port().toString(), "0"); Assert.assertEquals(conf.getWorkloadRefreshPeriodInSeconds().toString(), "600"); Assert.assertEquals(conf.getInitMaxNumPartitionsPerRoute().toString(), "10"); Assert.assertEquals(conf.getMaxNumPartitionsPerRoute().toString(), "20"); Assert.assertEquals(conf.getInitMaxNumWorkersPerRoute().toString(), "3"); Assert.assertEquals(conf.getMaxNumWorkersPerRoute().toString(), "5"); } catch (Exception e) { Assert.fail("No exception is expected"); } }
From source file:org.wikipedia.vlsergey.secretary.utils.AbstractDocumentBuilderPool.java
public void returnObject(DocumentBuilder documentBuilder) { try {//from www .j a va 2 s . c om pool.returnObject(documentBuilder); } catch (RuntimeException exc) { throw exc; } catch (Exception exc) { log.error(exc.getMessage(), exc); throw new NestableError(exc); } }
From source file:com.ebay.spine.WindowsWebDriverVNCProxy.java
@Override public void beforeRegistration() { boolean ok = false; int tries = 0; int maxTries = 5; while (!ok) { try {//from w ww . j a v a 2s .c o m tries++; prepareVM(); ok = true; } catch (RuntimeException e) { log.warn("Error happened when preparing the VM" + e.getMessage(), e); if (tries >= maxTries) { throw new GridException("Preparation of the VM crashes " + tries + " in a row.", e); } } } }
From source file:org.springdata.ehcache.support.EhacheExceptionTranslator.java
public DataAccessException translateExceptionIfPossible(RuntimeException x) { if (x instanceof DataAccessException) { return (DataAccessException) x; }/*from w w w. ja v a2 s. co m*/ if (!(x instanceof CacheException)) { return null; } return new EhcacheException(x.getMessage(), x); }
From source file:com.redhat.rhn.taskomatic.task.CobblerSyncTask.java
/** * {@inheritDoc}// ww w . j a v a 2s . c o m */ public void execute(JobExecutionContext ctxIn) throws JobExecutionException { try { XMLRPCInvoker invoker = (XMLRPCInvoker) MethodUtil .getClassFromConfig(CobblerXMLRPCHelper.class.getName()); Double mtime = null; try { mtime = (Double) invoker.invokeMethod("last_modified_time", new ArrayList()); } catch (XmlRpcFault e) { log.error("Error calling cobbler.", e); } CobblerDistroSyncCommand distSync = new CobblerDistroSyncCommand(); ValidatorError ve = distSync.syncNullDistros(); if (ve != null && distroWarnCount < 1) { TaskHelper.sendErrorEmail(log, ve.getMessage()); distroWarnCount++; } // if we need to update a profile's kickstart tree, do that now List<KickstartData> profiles = KickstartFactory.lookupKickstartDataByUpdateable(); for (KickstartData profile : profiles) { KickstartableTree tree = KickstartFactory.getNewestTree(profile.getRealUpdateType(), profile.getChannel().getId(), profile.getOrg()); if (tree != null && !tree.equals(profile.getTree())) { KickstartEditCommand cmd = new KickstartEditCommand(profile, null); cmd.updateKickstartableTree(profile.getChannel().getId(), profile.getOrg().getId(), tree.getId(), tree.getDefaultDownloadLocation("")); if (StringUtils.isNotEmpty(profile.getCobblerId())) { CobblerProfileEditCommand cpec = new CobblerProfileEditCommand(profile); cpec.store(); } } } log.debug("mtime: " + mtime.longValue() + ", last modified: " + LAST_UPDATED.get()); //If we got an mtime from cobbler and that mtime is before our last update // Then don't update anything if (mtime.longValue() < CobblerSyncTask.LAST_UPDATED.get()) { log.debug("Cobbler mtime is less than last change, skipping"); return; } log.debug("Syncing distros and profiles."); ve = distSync.store(); if (ve != null) { TaskHelper.sendErrorEmail(log, ve.getMessage()); } CobblerProfileSyncCommand profSync = new CobblerProfileSyncCommand(); profSync.store(); LAST_UPDATED.set((new Date()).getTime() / 1000 + 1); } catch (RuntimeException re) { log.error("RuntimeExceptionError trying to sync to cobbler: " + re.getMessage(), re); // Only throw up one error. Otherwise if say cobblerd is shutoff you can // possibly generate 1 stacktrace email per minute which is quite spammy. if (errorCount < 1) { errorCount++; log.error("re-throwing exception since we havent yet."); throw re; } log.error("Not re-throwing any more errors."); } }
From source file:tasly.greathealth.oms.web.cronjob.rest.resources.TaslyCronJobConfigResource.java
@POST public Response createOrUpdateJobConfig(@RequestBody final TaslyCronJobConfig config) { LOG.info("POST Cron job config." + config); TaslyCronJobConfig result = null;/*from ww w. ja v a2 s. co m*/ try { result = taslyCronjobFacade.createOrUpdateJobConfig(config); } catch (final RuntimeException r) { Response.ok(r.getMessage()).build(); } return Response.ok(result).build(); }
From source file:org.dspace.submit.lookup.CrossRefService.java
public List<Record> search(Context context, Set<String> dois, String apiKey) throws HttpException, IOException, JDOMException, ParserConfigurationException, SAXException { List<Record> results = new ArrayList<Record>(); if (dois != null && dois.size() > 0) { for (String record : dois) { try { HttpGet method = null;/*from w w w. ja v a 2 s. com*/ try { HttpClient client = new DefaultHttpClient(); client.getParams().setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, timeout); try { URIBuilder uriBuilder = new URIBuilder("http://www.crossref.org/openurl/"); uriBuilder.addParameter("pid", apiKey); uriBuilder.addParameter("noredirect", "true"); uriBuilder.addParameter("id", record); method = new HttpGet(uriBuilder.build()); } catch (URISyntaxException ex) { throw new HttpException("Request not sent", ex); } // Execute the method. HttpResponse response = client.execute(method); StatusLine statusLine = response.getStatusLine(); int statusCode = statusLine.getStatusCode(); if (statusCode != HttpStatus.SC_OK) { throw new RuntimeException("Http call failed: " + statusLine); } Record crossitem; try { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setValidating(false); factory.setIgnoringComments(true); factory.setIgnoringElementContentWhitespace(true); DocumentBuilder db = factory.newDocumentBuilder(); Document inDoc = db.parse(response.getEntity().getContent()); Element xmlRoot = inDoc.getDocumentElement(); Element queryResult = XMLUtils.getSingleElement(xmlRoot, "query_result"); Element body = XMLUtils.getSingleElement(queryResult, "body"); Element dataRoot = XMLUtils.getSingleElement(body, "query"); crossitem = CrossRefUtils.convertCrossRefDomToRecord(dataRoot); results.add(crossitem); } catch (Exception e) { log.warn(LogManager.getHeader(context, "retrieveRecordDOI", record + " DOI is not valid or not exist: " + e.getMessage())); } } finally { if (method != null) { method.releaseConnection(); } } } catch (RuntimeException rt) { log.error(rt.getMessage(), rt); } } } return results; }
From source file:com.vmware.o11n.plugin.powershell.model.generate.CmdletActionGenerator.java
public ScriptModule generateAction(IVSOFactoryClient factory, String actionName, String categoryName) { Validate.notNull(factory, "Factory can not be null."); Validate.notEmpty(actionName, "Action name must be provided."); Validate.notEmpty(categoryName, "Category name must be provided."); ScriptModule module = null;//from ww w . ja va2 s .c om try { ScriptModuleBuilder builder = new ScriptModuleBuilder().setName(actionName) .setDescription("Auto generated.").setResultType(Constants.TYPE_POWER_SHELL_REMOTE_PS_OBJECT); // Add system input params builder.addParameter(ACT_PARAM_NAME_HOST, "PowerShell:PowerShellHost"); builder.addParameter(ACT_PARAM_NAME_SESSION_ID, "string"); // Add cmdlet input params buildCmdletParams(builder); builder.setScript(buildCmdletScript()); module = builder.insert(categoryName, factory); } catch (RuntimeException exc) { log.warn(exc.getMessage()); throw (RuntimeException) exc; } return module; }
From source file:net.big_oh.algorithms.graph.clique.BronKerboschMaximalCliqueFinder.java
/** * This helper method merges two sets of maximal cliques, claiming newly * discovered maximal cliques and adding them to the set of well known * maximal cliques./* w ww . jav a2s . co m*/ * * @param wellKnownMaximalCliques * @param maximalCliqueDiscoveries */ private void processMaximalCliqueDiscoveries(Set<Set<V>> wellKnownMaximalCliques, Set<Set<V>> maximalCliqueDiscoveries) { for (Set<V> maximalCliqueDiscovery : maximalCliqueDiscoveries) { if (wellKnownMaximalCliques.add(maximalCliqueDiscovery)) { // this is the first discovery of the maximal clique ... // notify listeners for (MaximalCliqueFinderEventListener<V> listener : eventListeners) { try { listener.cliqueFound(maximalCliqueDiscovery); } catch (RuntimeException re) { logger.error(re.getMessage(), re); } } } } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskSaxLoader.CFAsteriskSaxLoaderClusterHandler.java
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException { try {/* ww w .j av a2 s . com*/ final String S_ProcName = "startElement"; assert qName.equals("Cluster"); CFAsteriskSaxLoader saxLoader = (CFAsteriskSaxLoader) getParser(); if (saxLoader == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser()"); } ICFAsteriskSchemaObj schemaObj = saxLoader.getSchemaObj(); if (schemaObj == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "getParser().getSchemaObj()"); } CFLibXmlCoreContext curContext = getParser().getCurContext(); ICFSecurityClusterObj useCluster = saxLoader.getUseCluster(); if (useCluster == null) { throw CFLib.getDefaultExceptionFactory().newNullArgumentException(getClass(), S_ProcName, 0, "saxLoader.useCluster"); } curContext.putNamedValue("Object", useCluster); } catch (RuntimeException e) { throw new RuntimeException("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } catch (Error e) { throw new Error("Near " + getParser().getLocationInfo() + ": Caught and rethrew " + e.getClass().getName() + " - " + e.getMessage(), e); } }