public void throwExceptionIfExists() { if (lastException != null) { throw bomb("Invalid config file", lastException); } }
public static void bombIf(boolean check, Supplier<String> msg) { if (check) { throw bomb(msg.get()); } }
private String getHostname() { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e) { throw bomb(e); } }
long revisionFromChange(String changeOutput) { Pattern pattern = Pattern.compile("^Change (\\d+) "); Matcher matcher = pattern.matcher(changeOutput); if (matcher.find()) { String changeNumber = matcher.group(1); return Long.parseLong(changeNumber); } throw bomb("Unable to parse revision from change: '" + changeOutput + "'"); }
public static <T> T instantiateConfigElement(GoCipher goCipher, Class<T> toGenerate) { try { boolean isPasswordEncrypter = PasswordEncrypter.class.isAssignableFrom(toGenerate); Constructor<T> tConstructor = isPasswordEncrypter ? toGenerate.getDeclaredConstructor(GoCipher.class) : toGenerate.getDeclaredConstructor(); tConstructor.setAccessible(true); return isPasswordEncrypter ? tConstructor.newInstance(goCipher) : tConstructor.newInstance(); } catch (Exception e1) { throw bomb("Error creating new instance of class " + toGenerate.getName(), e1); } } }
private void assertHasModifications() { if (modifications.size() == 0) { bomb(String.format("There are no modifications on material %s.", material)); } }
private void parseFileLines(Modification modification, String lines) { BufferedReader reader = new BufferedReader(new StringReader(lines)); try { for (String line = reader.readLine(); line != null; line = reader.readLine()) { parseFileLine(modification, line); } } catch (IOException e) { bomb(e); } }
public static CRArtifactType fromName(String artifactType) { try { return valueOf(artifactType); } catch (IllegalArgumentException e) { throw bomb("Illegal name in for the artifact type.[" + artifactType + "]", e); } } }
private String useConfiguredSiteUrl(String urlString) { try { return StageNotificationService.this.serverConfigService.siteUrlFor(urlString, false); } catch (URISyntaxException e) { throw bomb("Could not construct URL.", e); } }
public static String exec(File workingDirectory, String... commands) { try { Process process = Runtime.getRuntime().exec(commands, null, workingDirectory); return captureOutput(process).toString(); } catch (Exception e) { throw bomb(e); } }
private Object uniqueResult(DetachedCriteria criteria) { List results = getHibernateTemplate().findByCriteria(criteria); if (results.isEmpty()) { return null; } if (results.size() > 1) { throw bomb("expected unique results, got " + results.size() + ": " + results); } return results.get(0); }
boolean sendAndWaitForAcknowledgement(Message message) { final CountDownLatch wait = new CountDownLatch(1); sendWithCallback(message, wait::countDown); try { return wait.await(systemEnvironment.getWebsocketAckMessageTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { bomb(e); } return false; }
public List<Modification> parse(String svnLogOutput, String path, SAXBuilder builder) { try { Document document = builder.build(new StringReader(svnLogOutput)); return parseDOMTree(document, path); } catch (Exception e) { throw bomb("Unable to parse svn log output: " + svnLogOutput, e); } }
public boolean optionalAndMissingTag(Element e, ConfigTag tag, boolean optional) { boolean isMissingElement = !hasChild(e, tag); if (!optional && isMissingElement) { throw bomb("Non optional tag '" + tag + "' is not in config file. Found: " + elementOutput(e)); } return optional && isMissingElement; } }
@Override public boolean addWithoutValidation(PipelineConfig pipelineConfig) { PipelineConfigs part = this.getFirstEditablePartOrNull(); if(part == null) throw bomb("No editable configuration sources"); return part.addWithoutValidation(pipelineConfig); }
public JobInstance mostRecentCompleted(JobInstance champion) { try { if (getCompletedDate() != null && this.moreRecent(champion)) { return this; } } catch (Exception ex) { throw bomb(ex); } return champion; }
@Override public void sendMessage(GoMessage goMessage, long timeToLive) { try { producer.send(session.createObjectMessage(goMessage), producer.getDeliveryMode(), producer.getPriority(), timeToLive); } catch (JMSException e) { throw bomb(e); } }
public Task findFirstByType(Class<? extends Task> type) { Tasks tasks = findByType(type); if (tasks.size() > 0) { return tasks.first(); } else { throw bomb("Unable to find task of type " + type); } }
public List<Modification> modifications() { try { SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new StringReader(output)); return parseDOMTree(document); } catch (Exception e) { throw ExceptionUtils.bomb("Unable to parse hg log output: " + result.replaceSecretInfo(output), result.smudgedException(e)); } }
public List<Modification> latestModification() { CommandLine command = buildSvnLogCommandForLatestOne(); ConsoleResult result = executeCommand(command); String output = result.outputAsString(); try { return parseSvnLog(output); } catch (Exception e) { throw bomb(result.smudgedException(e)); } }