List of usage examples for java.lang NullPointerException getMessage
public String getMessage()
From source file:org.restcomm.connect.http.ExtensionsConfigurationEndpoint.java
protected Response postConfiguration(final MultivaluedMap<String, String> data, final MediaType responseType) { if (!isSuperAdmin()) { throw new InsufficientPermission(); }/*w w w . j a v a 2s . c o m*/ Sid accountSid = null; String accountSidQuery = data.getFirst("AccountSid"); if (accountSidQuery != null && !accountSidQuery.isEmpty()) { accountSid = new Sid(accountSidQuery); } //if extension doesnt exist, add new extension String extensionName = data.getFirst("ExtensionName"); ExtensionConfiguration extensionConfiguration = extensionsConfigurationDao .getConfigurationByName(extensionName); if (extensionConfiguration == null) { try { extensionConfiguration = createFrom(data, responseType); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } try { extensionsConfigurationDao.addConfiguration(extensionConfiguration); } catch (ConfigurationException exception) { return status(NOT_ACCEPTABLE).entity(exception.getMessage()).build(); } } if (accountSid != null) { try { Object configurationData = data.getFirst("ConfigurationData"); // if accountSid exists, then this configuration is account specific, if it doesnt then its global config extensionConfiguration.setConfigurationData(configurationData, extensionConfiguration.getConfigurationType()); extensionsConfigurationDao.addAccountExtensionConfiguration(extensionConfiguration, accountSid); } catch (ConfigurationException exception) { return status(NOT_ACCEPTABLE).entity(exception.getMessage()).build(); } } if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(extensionConfiguration), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(extensionConfiguration); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }
From source file:com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImplTest.java
/** * Test method for/*from w w w .j a va 2 s . c om*/ * {@link com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImpl#getQueryResponse(java.lang.String)} * . */ @Ignore @Test public void testGetQueryResponse() { logger.debug("RUNNING TEST FOR BASIC QUERY RESPONSE"); jiraDataFactory = new JiraDataFactoryImpl(properties.getProperty("jira.credentials"), properties.getProperty("jira.base.url"), properties.getProperty("jira.query.endpoint")); jiraDataFactory.buildBasicQuery(query); try { JSONArray rs = jiraDataFactory.getQueryResponse(); /* * Testing actual JSON for values */ JSONArray dataMainArry = new JSONArray(); JSONObject dataMainObj = new JSONObject(); dataMainArry = (JSONArray) rs.get(0); dataMainObj = (JSONObject) dataMainArry.get(0); logger.info("Basic query response: " + dataMainObj.get("fields").toString()); // fields assertTrue("No valid Number was found", dataMainObj.get("fields").toString().length() >= 1); } catch (NullPointerException npe) { fail("There was a problem with an object used to connect to Jira during the test\n" + npe.getMessage() + " caused by: " + npe.getCause()); } catch (ArrayIndexOutOfBoundsException aioobe) { fail("The object returned from Jira had no JSONObjects in it during the test; try increasing the scope of your test case query and try again\n" + aioobe.getMessage() + " caused by: " + aioobe.getCause()); } catch (IndexOutOfBoundsException ioobe) { logger.info("JSON artifact may be empty - re-running test to prove this out..."); JSONArray rs = jiraDataFactory.getQueryResponse(); /* * Testing actual JSON for values */ String strRs = new String(); strRs = rs.toString(); logger.info("Basic query response: " + strRs); assertEquals("There was nothing returned from Jira that is consistent with a valid response.", "[[]]", strRs); } catch (Exception e) { fail("There was an unexpected problem while connecting to Jira during the test\n" + e.getMessage() + " caused by: " + e.getCause()); } }
From source file:org.apache.zeppelin.scheduler.Job.java
public void run() { JobProgressPoller progressUpdator = null; try {//from w w w . j a v a2 s .c o m progressUpdator = new JobProgressPoller(this, progressUpdateIntervalMs); progressUpdator.start(); dateStarted = new Date(); result = jobRun(); this.exception = null; errorMessage = null; dateFinished = new Date(); progressUpdator.terminate(); } catch (NullPointerException e) { logger().error("Job failed", e); progressUpdator.terminate(); this.exception = e; result = e.getMessage(); errorMessage = getStack(e); dateFinished = new Date(); } catch (Throwable e) { logger().error("Job failed", e); progressUpdator.terminate(); this.exception = e; result = e.getMessage(); errorMessage = getStack(e); dateFinished = new Date(); } finally { //aborted = false; } }
From source file:com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImplTest.java
/** * Test method for//from ww w .j av a 2s . c o m * {@link com.capitalone.dashboard.datafactory.jira.JiraDataFactoryImpl#getPagingQueryResponse()} * . */ @Ignore @Test public void testGetPagingQueryResponse() { logger.debug("RUNNING TEST FOR PAGING QUERY RESPONSE"); jiraDataFactory = new JiraDataFactoryImpl(1, properties.getProperty("jira.credentials"), properties.getProperty("jira.base.url"), properties.getProperty("jira.query.endpoint")); jiraDataFactory.buildBasicQuery(query); jiraDataFactory.buildPagingQuery(0); try { JSONArray rs = jiraDataFactory.getPagingQueryResponse(); /* * Testing actual JSON for values */ JSONArray dataMainArry = new JSONArray(); JSONObject dataMainObj = new JSONObject(); dataMainArry = (JSONArray) rs.get(0); dataMainObj = (JSONObject) dataMainArry.get(0); logger.info("Paging query response: " + dataMainObj.get("fields").toString()); // fields assertTrue("No valid Number was found", dataMainObj.get("fields").toString().length() >= 1); } catch (NullPointerException npe) { fail("There was a problem with an object used to connect to Jira during the test:\n" + npe.getMessage() + " caused by: " + npe.getCause()); } catch (ArrayIndexOutOfBoundsException aioobe) { fail("The object returned from Jira had no JSONObjects in it during the test; try increasing the scope of your test case query and try again.\n" + aioobe.getMessage() + " caused by: " + aioobe.getCause()); } catch (IndexOutOfBoundsException ioobe) { logger.info("JSON artifact may be empty - re-running test to prove this out..."); JSONArray rs = jiraDataFactory.getPagingQueryResponse(); /* * Testing actual JSON for values */ String strRs = new String(); strRs = rs.toString(); logger.info("Paging query response: " + strRs); assertEquals("There was nothing returned from Jira that is consistent with a valid response.", "[[]]", strRs); } catch (Exception e) { fail("There was an unexpected problem while connecting to Jira during the test:\n" + e.getMessage() + " caused by: " + e.getCause()); } }
From source file:com.yahoo.pulsar.client.impl.ConsumerBase.java
@Override public CompletableFuture<Void> acknowledgeAsync(Message message) { try {/*www. j av a 2 s .c o m*/ return acknowledgeAsync(message.getMessageId()); } catch (NullPointerException npe) { return FutureUtil.failedFuture(new PulsarClientException.InvalidMessageException(npe.getMessage())); } }
From source file:com.yahoo.pulsar.client.impl.ConsumerBase.java
@Override public CompletableFuture<Void> acknowledgeCumulativeAsync(Message message) { try {/* w w w . ja va 2 s . c o m*/ return acknowledgeCumulativeAsync(message.getMessageId()); } catch (NullPointerException npe) { return FutureUtil.failedFuture(new PulsarClientException.InvalidMessageException(npe.getMessage())); } }
From source file:dentex.youtube.downloader.UpgradeApkActivity.java
void callDownloadApk(String ver) { String apklink = getString(R.string.apk_download_sourceforge_link, ver); apkFilename = getString(R.string.apk_filename, ver); downloadManager = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); Request request = new Request(Uri.parse(apklink)); fileUri = Uri.parse(dir.toURI() + apkFilename); request.setDestinationUri(fileUri);//from www .j a v a 2 s . com request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setTitle("YouTube Downloader v" + ver); try { enqueue = downloadManager.enqueue(request); } catch (IllegalArgumentException e) { Log.e(DEBUG_TAG, "callDownloadApk: " + e.getMessage()); BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", e.getMessage(), e); YTD.NoDownProvPopUp(this); } catch (NullPointerException ne) { Log.e(DEBUG_TAG, "callDownloadApk: " + ne.getMessage()); BugSenseHandler.sendExceptionMessage(DEBUG_TAG + "-> callDownloadApk: ", ne.getMessage(), ne); Toast.makeText(this, getString(R.string.error), Toast.LENGTH_SHORT).show(); } }
From source file:plbtw.klmpk.barang.hilang.controller.BarangController.java
@RequestMapping(method = RequestMethod.GET, produces = "application/json") public CustomResponseMessage /*Collection<Barang>*/ getAllBarang(@RequestHeader String apiKey) { try {// w w w.j a va 2s .c o m if (!authApiKey(apiKey)) { return new CustomResponseMessage(HttpStatus.FORBIDDEN, "Please use your api key to authentication"); } LogRequest temp = DependencyFactory.createLog(apiKey, "Get"); if (checkRateLimit(RATE_LIMIT, apiKey)) { return new CustomResponseMessage(HttpStatus.BANDWIDTH_LIMIT_EXCEEDED, "Please wait a while, you have reached your rate limit"); } Log log = new Log(); log.setApiKey(temp.getApiKey()); log.setStatus(temp.getStatus()); log.setTimeRequest(temp.getTime_request()); logService.addLog(log); List<Barang> allBarang = (List<Barang>) barangService.getAllBarang(); for (Barang barang : allBarang) { Link selfLink = linkTo(BarangController.class).withSelfRel(); barang.add(selfLink); } CustomResponseMessage result = new CustomResponseMessage(); result.add(linkTo(BarangController.class).withSelfRel()); result.setHttpStatus(HttpStatus.FOUND); result.setMessage("Success"); result.setResult(allBarang); return result; } catch (NullPointerException ex) { return new CustomResponseMessage(HttpStatus.NOT_FOUND, "Data not found"); } catch (Exception ex) { return new CustomResponseMessage(HttpStatus.FORBIDDEN, ex.getMessage()); } }
From source file:plbtw.klmpk.barang.hilang.controller.BarangController.java
@RequestMapping(value = "/find/{id}", method = RequestMethod.GET, produces = "application/json") public CustomResponseMessage findBarang(@RequestHeader String apiKey, @PathVariable("id") long id) { try {/*from ww w . j a va2s. co m*/ if (!authApiKey(apiKey)) { return new CustomResponseMessage(HttpStatus.FORBIDDEN, "Please use your api key to authentication"); } LogRequest temp = DependencyFactory.createLog(apiKey, "Get"); if (checkRateLimit(RATE_LIMIT, apiKey)) { return new CustomResponseMessage(HttpStatus.BANDWIDTH_LIMIT_EXCEEDED, "Please wait a while, you have reached your rate limit"); } Log log = new Log(); log.setApiKey(temp.getApiKey()); log.setStatus(temp.getStatus()); log.setTimeRequest(temp.getTime_request()); logService.addLog(log); List<Barang> rsBarang = new ArrayList<>(); Barang barang = barangService.getBarang(id); Link selfLink = linkTo(UserController.class).withSelfRel(); barang.add(selfLink); rsBarang.add(barang); CustomResponseMessage result = new CustomResponseMessage(); result.add(linkTo(BarangController.class).withSelfRel()); result.setHttpStatus(HttpStatus.FOUND); result.setMessage("Success"); result.setResult(rsBarang); return result; } catch (NullPointerException ex) { return new CustomResponseMessage(HttpStatus.NOT_FOUND, "Data not found"); } catch (Exception ex) { return new CustomResponseMessage(HttpStatus.BAD_REQUEST, ex.getMessage()); } }
From source file:org.apache.hadoop.hbase.mapreduce.TestTableMapReduceBase.java
protected void verify(String tableName) throws IOException { HTable table = new HTable(UTIL.getConfiguration(), tableName); boolean verified = false; long pause = UTIL.getConfiguration().getLong("hbase.client.pause", 5 * 1000); int numRetries = UTIL.getConfiguration().getInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 5); for (int i = 0; i < numRetries; i++) { try {//w ww. j a v a2 s . c om getLog().info("Verification attempt #" + i); verifyAttempt(table); verified = true; break; } catch (NullPointerException e) { // If here, a cell was empty. Presume its because updates came in // after the scanner had been opened. Wait a while and retry. getLog().debug("Verification attempt failed: " + e.getMessage()); } try { Thread.sleep(pause); } catch (InterruptedException e) { // continue } } assertTrue(verified); }