List of usage examples for java.lang NullPointerException getMessage
public String getMessage()
From source file:org.droidmate.uiautomator2daemon.UiAutomator2DaemonDriver.java
/** * @see #dumpWindowHierarchyProtectingAgainstException *//*from w ww. ja va 2 s. com*/ // Note on read/write permissions: // http://stackoverflow.com/questions/23527767/open-failed-eacces-permission-denied private boolean tryDumpWindowHierarchy(File windowDumpFile) { try { Log.v(uiaDaemon_logcatTag, String.format("Trying to create dump file '%s'", windowDumpFile.toString())); Log.v(uiaDaemon_logcatTag, "Executing dump"); this.device.dumpWindowHierarchy(windowDumpFile); Log.v(uiaDaemon_logcatTag, "Dump executed"); if (windowDumpFile.exists()) { return true; } else { Log.w(uiaDaemon_logcatTag, ".dumpWindowHierarchy returned, but the dumped file doesn't exist!"); return false; } } catch (NullPointerException e) { Log.w(uiaDaemon_logcatTag, "Caught NPE while dumping window hierarchy. Msg: " + e.getMessage()); return false; } catch (IllegalArgumentException e) { Log.w(uiaDaemon_logcatTag, "Caught IllegalArgumentException while dumping window hierarchy. Msg: " + e.getMessage()); return false; } catch (IOException e) { Log.w(uiaDaemon_logcatTag, "Caught IOException while dumping window hierarchy. Msg: " + e.getMessage()); return false; } }
From source file:org.droidmate.uiautomator_daemon.UiAutomatorDaemonDriver.java
/** * @see #dumpWindowHierarchyProtectingAgainstException *//* w w w .j a v a2 s . c o m*/ private boolean tryDumpWindowHierarchy(File windowDumpFile) { try { ui.getUiDevice().dumpWindowHierarchy(windowDumpFile.getName()); if (windowDumpFile.exists()) { return true; } else { Log.w(uiaDaemon_logcatTag, ".dumpWindowHierarchy returned, but the dumped file doesn't exist!"); return false; } } catch (NullPointerException e) { Log.w(uiaDaemon_logcatTag, "Caught NPE while dumping window hierarchy. Msg: " + e.getMessage()); return false; } catch (IllegalArgumentException e) { Log.w(uiaDaemon_logcatTag, "Caught IllegalArgumentException while dumping window hierarchy. Msg: " + e.getMessage()); return false; } }
From source file:org.finra.dm.dao.S3DaoTest.java
@Test public void testDeleteDirectoryNullParamsDto() { // Try to delete an S3 directory when transfer request parameters DTO is null. try {/*from w ww. j a va 2 s.c o m*/ s3Dao.deleteDirectory(null); fail("Suppose to throw a NullPointerException."); } catch (NullPointerException e) { assertNull(e.getMessage()); } }
From source file:org.finra.dm.dao.S3DaoTest.java
@Test public void testAbortMultipartUploadsNullParamsDto() { // Try to abort multipart uploads when transfer request parameters DTO is null. try {//w w w. j a va 2 s . c om s3Dao.abortMultipartUploads(null, new Date()); fail("Suppose to throw a NullPointerException."); } catch (NullPointerException e) { assertNull(e.getMessage()); } }
From source file:org.restcomm.connect.http.AccountsEndpoint.java
protected Response putAccount(final MultivaluedMap<String, String> data, final MediaType responseType) { //First check if the account has the required permissions in general, this way we can fail fast and avoid expensive DAO operations checkPermission("RestComm:Create:Accounts"); // check account level depth. If we're already at third level no sub-accounts are allowed to be created List<String> accountLineage = userIdentityContext.getEffectiveAccountLineage(); if (accountLineage.size() >= 2) { // there are already 2+1=3 account levels. Sub-accounts at 4th level are not allowed return status(BAD_REQUEST).entity( buildErrorResponseBody("This account is not allowed to have sub-accounts", responseType)) .type(responseType).build(); }/* w w w .j a v a 2s .co m*/ // what if effectiveAccount is null ?? - no need to check since we checkAuthenticatedAccount() in AccountsEndoint.init() final Sid sid = userIdentityContext.getEffectiveAccount().getSid(); Account account = null; try { account = createFrom(sid, data); } catch (final NullPointerException exception) { return status(BAD_REQUEST).entity(exception.getMessage()).build(); } catch (PasswordTooWeak passwordTooWeak) { return status(BAD_REQUEST).entity(buildErrorResponseBody("Password too weak", responseType)) .type(responseType).build(); } // If Account already exists don't add it again /* Account creation rules: - either be Administrator or have the following permission: RestComm:Create:Accounts - only Administrators can choose a role for newly created accounts. Normal users will create accounts with the same role as their own. */ if (accountsDao.getAccount(account.getSid()) == null && !account.getEmailAddress().equalsIgnoreCase("administrator@company.com")) { final Account parent = accountsDao.getAccount(sid); if (parent.getStatus().equals(Account.Status.ACTIVE) && isSecuredByPermission("RestComm:Create:Accounts")) { if (!hasAccountRole(getAdministratorRole()) || !data.containsKey("Role")) { account = account.setRole(parent.getRole()); } accountsDao.addAccount(account); // Create default SIP client data MultivaluedMap<String, String> clientData = new MultivaluedMapImpl(); String username = data.getFirst("EmailAddress").split("@")[0]; clientData.add("Login", username); clientData.add("Password", data.getFirst("Password")); clientData.add("FriendlyName", account.getFriendlyName()); clientData.add("AccountSid", account.getSid().toString()); Client client = clientDao.getClient(clientData.getFirst("Login")); if (client == null) { client = createClientFrom(account.getSid(), clientData); clientDao.addClient(client); } } else { throw new InsufficientPermission(); } } else { return status(CONFLICT).entity("The email address used for the new account is already in use.").build(); } if (APPLICATION_JSON_TYPE == responseType) { return ok(gson.toJson(account), APPLICATION_JSON).build(); } else if (APPLICATION_XML_TYPE == responseType) { final RestCommResponse response = new RestCommResponse(account); return ok(xstream.toXML(response), APPLICATION_XML).build(); } else { return null; } }
From source file:azkaban.jobtype.ReportalTeradataRunner.java
@Override protected void runReportal() throws Exception { System.out.println("Reportal Teradata: Setting up Teradata"); List<Exception> exceptions = new ArrayList<Exception>(); Class.forName("com.teradata.jdbc.TeraDriver"); String connectionString = props.getString("reportal.teradata.connection.string", null); String user = props.getString("reportal.teradata.username", null); String pass = props.getString("reportal.teradata.password", null); if (user == null) { System.out.println("Reportal Teradata: Configuration incomplete"); throw new RuntimeException("The reportal.teradata.username variable was not defined."); }//from w ww .j a v a 2 s.c o m if (pass == null) { System.out.println("Reportal Teradata: Configuration incomplete"); throw new RuntimeException("The reportal.teradata.password variable was not defined."); } DataSource teraDataSource = new TeradataDataSource(connectionString, user, pass); Connection conn = teraDataSource.getConnection(); String sqlQueries[] = cleanAndGetQueries(jobQuery, proxyUser); int numQueries = sqlQueries.length; for (int i = 0; i < numQueries; i++) { try { String queryLine = sqlQueries[i]; // Only store results from the last statement if (i == numQueries - 1) { PreparedStatement stmt = prepareStatement(conn, queryLine); stmt.execute(); ResultSet rs = stmt.getResultSet(); outputQueryResult(rs, outputStream); stmt.close(); } else { try { PreparedStatement stmt = prepareStatement(conn, queryLine); stmt.execute(); stmt.close(); } catch (NullPointerException e) { // An empty query (or comment) throws a NPE in JDBC. Yay! System.err.println( "Caught NPE in execute call because report has a NOOP query: " + queryLine); } } } catch (Exception e) { // Catch and continue. Delay exception throwing until we've run all queries in this task. System.out.println("Reportal Teradata: SQL query failed. " + e.getMessage()); e.printStackTrace(); exceptions.add(e); } } if (exceptions.size() > 0) { throw new CompositeException(exceptions); } System.out.println("Reportal Teradata: Ended successfully"); }
From source file:edu.ucsd.sbrg.escher.model.EscherMap.java
/** * Post-processes {@link EscherMap} and populates internal helper fields. *//* w w w. j a v a2 s .co m*/ public void processMap() { try { // Set mid-marker for every reaction by going through its nodes and checking which // one is a mid-marker. reactions.forEach((k, r) -> { r.getNodes().forEach((s) -> { if (nodes.get(s).getType() == Node.Type.midmarker) { r.setMidmarker(nodes.get(s)); } }); }); // Set nodeRefIds for metabolites. reactions.forEach((k, r) -> { r.getMetabolites().forEach((mk, mv) -> { r.getNodes().forEach((s) -> { try { Node node = nodes.get(s); if (node.getBiggId() == null) { return; } if (node.getBiggId().equals(mv.getId())) { mv.setNodeRefId(node.getId()); } } catch (NullPointerException ex) { ex.getMessage(); } }); }); }); // Bigg2Reactions. reactions.forEach((k, v) -> { if (!bigg2reactions.containsKey(v.getBiggId())) { Set<String> reactionSet = new HashSet<>(); reactionSet.add(v.getId()); bigg2reactions.put(v.getBiggId(), reactionSet); } }); // Bigg2Nodes. nodes.forEach((k, v) -> { if (v.getBiggId() == null) { return; } if (!bigg2nodes.containsKey(v.getBiggId())) { Set<String> nodeSet = new HashSet<>(); nodeSet.add(v.getId()); bigg2nodes.put(v.getBiggId(), nodeSet); } else { bigg2nodes.get(v.getBiggId()).add(v.getId()); } }); // Store compartments. nodes.forEach((k, v) -> { EscherCompartment compartment = new EscherCompartment(); if (v.getCompartment() == null) { return; } compartment.setId(v.getCompartment()); if (!compartments.containsKey(compartment.getId())) { compartments.put(compartment.getId(), compartment); } }); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:com.github.cherimojava.data.mongo.io._DeEncoding.java
@Test public void explicitIdMustBeSetOnSave() { ExplicitIdEntity pe = factory.create(ExplicitIdEntity.class); pe.setName("sme").setName(null);// else it won't try to save try {/*ww w .j a v a 2 s . c o m*/ pe.save(); fail("should throw an exception"); } catch (NullPointerException e) { assertThat(e.getMessage(), containsString("An explicit defined Id ")); } pe.setName("some"); pe.save(); }
From source file:com.microsoft.office365.starter.models.O365CalendarModel.java
public void postCreatedEvent(final Activity activity, final O365CalendarModel.O365Calendar_Event eventToAdd) { try {/*from w w w . ja va 2 s . co m*/ Event newEvent = eventToAdd.getEvent(); if (newEvent.getEnd().before(newEvent.getStart())) { OperationResult opResult = new OperationResult("Add event", "Event was not added. End cannot be before start.", "-1"); mEventOperationCompleteListener.onOperationComplete(opResult); return; } // This request returns the user's primary calendar. if you want to get // a different calendar in the user's calendar collection in Office 365, // ListenableFuture<Event> addedEvent = mApplication.getCalendarClient().getMe().getCalendars() .getById(Constants.CALENDER_ID).getEvents().add(newEvent); // addedEvent. Futures.addCallback(addedEvent, new FutureCallback<Event>() { @Override public void onSuccess(final Event result) { OperationResult opResult = new OperationResult("Add event", "Added event", result.getId()); eventToAdd.setEvent(result); // Update event collection.ITEM_MAP with updated Event.ID if (mCalendarEvents.ITEM_MAP.containsKey(tempNewEventId.toString())) mCalendarEvents.ITEM_MAP.remove(tempNewEventId.toString()); tempNewEventId = null; mCalendarEvents.ITEM_MAP.put(result.getId(), eventToAdd); sortInDateTimeOrder(mCalendarEvents.ITEMS); mEventOperationCompleteListener.onOperationComplete(opResult); } @Override public void onFailure(final Throwable t) { Log.e(t.getMessage(), "Create event"); OperationResult opResult = new OperationResult("Add event", "Error on add event: " + getErrorMessage(t.getMessage()), "-1"); tempNewEventId = null; mEventOperationCompleteListener.onOperationComplete(opResult); } }); } catch (NullPointerException npe) { Log.e("Null pointer on add new event in O365CalendarModel.postCreatedEvent : " + npe.getMessage(), "null pointer"); OperationResult opResult = new OperationResult("Add event", "Error on add event - null pointer", "-1"); mEventOperationCompleteListener.onOperationComplete(opResult); } }
From source file:de.dmarcini.submatix.pclogger.gui.ProgramProperetysDialog.java
/** * zeige eine Fehlermeldung erstellt: 26.08.2013 * /*from ww w. j a v a2s . c om*/ * @param message * void */ private void showErrorDialog(String message) { ImageIcon icon = null; try { icon = new ImageIcon(MainCommGUI.class.getResource("/de/dmarcini/submatix/pclogger/res/Terminate.png")); JOptionPane.showMessageDialog(this, message, LangStrings.getString("MainCommGUI.errorDialog.headline"), JOptionPane.INFORMATION_MESSAGE, icon); } catch (NullPointerException ex) { lg.error("ERROR showErrorBox <" + ex.getMessage() + "> ABORT!"); return; } catch (MissingResourceException ex) { lg.error("ERROR showErrorBox <" + ex.getMessage() + "> ABORT!"); return; } catch (ClassCastException ex) { lg.error("ERROR showErrorBox <" + ex.getMessage() + "> ABORT!"); return; } }