List of usage examples for java.lang NullPointerException printStackTrace
public void printStackTrace()
From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java
private boolean checkout() { boolean saidGoodbye = false; String checkoutUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/checkout"; String getResult = HttpUtils.getUrlData(checkoutUrl); JSONObject checkout;//ww w. ja v a2 s .com try { checkout = (JSONObject) new JSONTokener(getResult).nextValue(); String result = checkout.optString(InformOnlineState.RESULT, InformOnlineState.ERROR); if (result.equals(InformOnlineState.OK)) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "said goodbye to Group Complete"); } else { if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, t + "device checkout unnecessary"); } saidGoodbye = true; } catch (NullPointerException e) { // Communication error if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "no getResult to parse. Communication error with node.js server?"); e.printStackTrace(); } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse getResult " + getResult); e.printStackTrace(); } finally { // Running a checkout ALWAYS "signs us out" mSignedIn = false; } Collect.getInstance().getInformOnlineState().setSession(null); return saidGoodbye; }
From source file:com.smi.travel.monitor.MonitorAmadeus.java
protected String getField(String name) { String val = null; try {/* ww w .ja v a 2s. c o m*/ MAmadeus ama = amadeusMap.get(name); String line = null; if (StringUtils.isEmpty(ama.getSection())) { return null; } if (ama.getNodlm().isEmpty()) { ArrayList<String> lines = (ArrayList<String>) sectionData.get(ama.getSection()); // System.out.println("lines size(" + lines.size() + ")"); // System.out.println("Found class -> " + obj.getClass().getName()); String foundLine = lines.get(0); line = foundLine.substring(ama.getSection().length()); val = line.substring(ama.getStartlength() - 1, ama.getStartlength() - 1 + ama.getLength()); } else { int node = Integer.parseInt(ama.getNodlm()); ArrayList<String> sectionLine = (ArrayList<String>) sectionData.get(ama.getSection()); String foundLine = sectionLine.get(0); line = foundLine.substring(ama.getSection().length()); String[] lines = line.split(NODE_SEPARATOR); String foundNode = lines[node - 1]; val = foundNode.substring(ama.getStartlength() - 1, ama.getStartlength() - 1 + ama.getLength()); } System.out.println("Key [" + name + "], Value [" + val + "]"); } catch (NullPointerException ne) { System.out.println("NullPointerException on field [" + name + "]"); ne.printStackTrace(); System.out.println("Set value [" + name + "] to 0"); val = new String("0"); } return val.trim(); }
From source file:it.mb.whatshare.GCMIntentService.java
private void readWhitelist() { File whitelist = new File(getFilesDir(), MainActivity.INBOUND_DEVICES_FILENAME); // if whitelist doesn't exist, don't bother long lastModified = whitelist.exists() ? whitelist.lastModified() : Long.MIN_VALUE; if (lastCheckedWhitelist < lastModified) { FileInputStream fis = null; try {//from w ww .j av a2 s . c o m fis = openFileInput(MainActivity.INBOUND_DEVICES_FILENAME); ObjectInputStream ois = new ObjectInputStream(fis); Object read = ois.readObject(); @SuppressWarnings("unchecked") List<PairedDevice> devices = (ArrayList<PairedDevice>) read; senderWhitelist = new HashSet<String>(); for (PairedDevice device : devices) { try { senderWhitelist.add(String.valueOf(device.id.hashCode())); } catch (NullPointerException e) { // backward compatibility... devices didn't have an ID senderWhitelist.add(String.valueOf(device.name.hashCode())); } } } catch (FileNotFoundException e) { // it's ok, no whitelist, all messages are rejected } catch (StreamCorruptedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO here the error should be notified I guess e.printStackTrace(); } finally { if (fis != null) try { fis.close(); } catch (IOException e) { // can't do much... e.printStackTrace(); } } // whatever happens, don't keep checking for nothing lastCheckedWhitelist = lastModified; } }
From source file:com.radicaldynamic.groupinform.services.InformOnlineService.java
private boolean checkin() { // Assume we are registered unless told otherwise boolean registered = true; List<NameValuePair> params = new ArrayList<NameValuePair>(); params.add(new BasicNameValuePair("deviceId", Collect.getInstance().getInformOnlineState().getDeviceId())); params.add(/*from w w w . j ava 2s . c o m*/ new BasicNameValuePair("deviceKey", Collect.getInstance().getInformOnlineState().getDeviceKey())); params.add(new BasicNameValuePair("fingerprint", Collect.getInstance().getInformOnlineState().getDeviceFingerprint())); try { params.add(new BasicNameValuePair("lastCheckinWith", this.getPackageManager().getPackageInfo(this.getPackageName(), 0).versionName)); } catch (NameNotFoundException e1) { params.add(new BasicNameValuePair("lastCheckinWith", "unknown")); } String checkinUrl = Collect.getInstance().getInformOnlineState().getServerUrl() + "/checkin"; String postResult = HttpUtils.postUrlData(checkinUrl, params); JSONObject checkin; try { checkin = (JSONObject) new JSONTokener(postResult).nextValue(); String result = checkin.optString(InformOnlineState.RESULT, InformOnlineState.FAILURE); if (result.equals(InformOnlineState.OK)) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "successful checkin"); Collect.getInstance().getInformOnlineState().setExpired(false); // Update device role -- it might have changed Collect.getInstance().getInformOnlineState() .setDeviceRole(checkin.optString("role", AccountDevice.ROLE_UNASSIGNED)); } else if (result.equals(InformOnlineState.EXPIRED)) { if (Collect.Log.INFO) Log.i(Collect.LOGTAG, t + "associated order is expired; marking device as expired"); Collect.getInstance().getInformOnlineState().setExpired(true); } else if (result.equals(InformOnlineState.FAILURE)) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "checkin unsuccessful"); registered = false; } else { // Something bad happened if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "system error while processing postResult"); } } catch (NullPointerException e) { // Communication error if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "no postResult to parse. Communication error with node.js server?"); e.printStackTrace(); } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse postResult " + postResult); e.printStackTrace(); } // Clear the session for subsequent requests and reset stored state if (registered == false) Collect.getInstance().getInformOnlineState().resetDevice(); return registered; }
From source file:com.mariogrip.octodroid.mainActivity.java
public void runner() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); int sync = 3000; try {/*from ww w. ja va 2s . c o m*/ sync = Integer.parseInt(prefs.getString("sync", "2")); if (sync < 999) { sync = 1000; } if (sync > 7001) { sync = 7000; } } catch (Exception e) { sync = 3000; } try { if (running) { util.logD("Stopping runner, Might started twice"); return; } if (!running) { util.logD("OneRunStarted"); running = true; } timerTask = new TimerTask() { @Override public void run() { decodejobs(); runOnUiThread(new Runnable() { @Override public void run() { try { Fill(); } catch (Exception e) { } } }); } }; timer.schedule(timerTask, 0, sync); } catch (NullPointerException v) { v.printStackTrace(); } }
From source file:org.schabi.newpipe.services.youtube.YoutubeVideoExtractor.java
@Override public VideoInfo.AudioStream[] getAudioStreams() { try {/*from ww w . j a va 2 s . com*/ String dashManifest = playerArgs.getString("dashmpd"); return parseDashManifest(dashManifest, decryptionCode); } catch (NullPointerException e) { Log.e(TAG, "Could not find \"dashmpd\" upon the player args (maybe no dash manifest available)."); } catch (Exception e) { e.printStackTrace(); } return new VideoInfo.AudioStream[0]; }
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."); }/*w w w.j a v a 2s. 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:storybook.ui.table.renderer.AttributesTableCellRenderer.java
@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { MainFrame mainFrame = (MainFrame) table.getClientProperty(ClientPropertyName.MAIN_FRAME.toString()); JLabel lbText = (JLabel) super.getTableCellRendererComponent(table, null, isSelected, hasFocus, row, column);/*from w w w.j ava2s .co m*/ if (value == null || value instanceof String) { return lbText; } try { @SuppressWarnings("unchecked") List<Attribute> list = (List<Attribute>) value; if (list == null || list.isEmpty()) { return lbText; } try { lbText.setText(StringUtils.join(list, ", ")); } catch (NullPointerException e) { // ignore } } catch (LazyInitializationException lie) { BookModel model = mainFrame.getBookModel(); Session session = model.beginTransaction(); @SuppressWarnings("unchecked") List<Attribute> list = (List<Attribute>) value; try { for (Attribute property : list) { session.refresh(property); } lbText.setText(StringUtils.join(list, ", ")); model.commit(); } catch (Exception e) { // ignore // e.printStackTrace(); } } catch (Exception e) { e.printStackTrace(); } return lbText; }
From source file:uk.org.openeyes.diagnostics.AbstractFieldProcessor.java
/** * Determine if the given file contains valid XML. * * @param file existing file to test; must contain valid XML. * * @return true if the file could be successfully parsed; false otherwise. *///from w w w . j a v a 2s . c o m protected boolean validate(File file) { boolean valid = false; InputStream istream = null; try { DocumentBuilderFactory dBF = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dBF.newDocumentBuilder(); istream = new FileInputStream(file); Document doc = builder.parse(istream); valid = true; } catch (NullPointerException e) { // nothing to do e.printStackTrace(); } catch (Exception e) { // nothing to do e.printStackTrace(); } finally { if (istream != null) { try { istream.close(); } catch (IOException ioex) { // nothing to do ioex.printStackTrace(); } } if (!valid) { // create appropriate report: HumphreyFieldMetaData metaData = new HumphreyFieldMetaData(this.regex); metaData.addFieldError(DbUtils.ERROR_BADLY_FORMED_XML); this.generateReport(file, metaData, false); } return valid; } }
From source file:org.mewx.wenku8.fragment.NavigationDrawerFragment.java
/** * Judge whether the dark mode is open. If is open, close it; else open it. *///w w w . java 2s .c om private void openOrCloseDarkMode() { // sdk ver is too low if (Build.VERSION.SDK_INT < 16) { try { if (fakeDarkSwitcher) { // In dark mode, so close it ((TextView) mainActivity.findViewById(R.id.main_menu_dark_mode_switcher)) .setTextColor(getResources().getColor(R.color.menu_text_color)); } else { // In light mode, so open it ((TextView) mainActivity.findViewById(R.id.main_menu_dark_mode_switcher)) .setTextColor(getResources().getColor(R.color.menu_item_blue)); } } catch (NullPointerException e) { Toast.makeText(mainActivity, "NullPointerException in openOrCloseDarkMode(); sdk16-", Toast.LENGTH_SHORT).show(); e.printStackTrace(); } } else { try { if (fakeDarkSwitcher) { // In dark mode, so close it ((TextView) mainActivity.findViewById(R.id.main_menu_dark_mode_switcher)) .setTextColor(getResources().getColor(R.color.menu_text_color)); mainActivity.findViewById(R.id.main_menu_dark_mode_switcher) .setBackground(getResources().getDrawable(R.drawable.btn_menu_item)); } else { // In light mode, so open it ((TextView) mainActivity.findViewById(R.id.main_menu_dark_mode_switcher)) .setTextColor(getResources().getColor(R.color.menu_text_color_selected)); mainActivity.findViewById(R.id.main_menu_dark_mode_switcher) .setBackground(getResources().getDrawable(R.drawable.btn_menu_item_selected)); } } catch (NullPointerException e) { Toast.makeText(mainActivity, "NullPointerException in openOrCloseDarkMode();", Toast.LENGTH_SHORT) .show(); e.printStackTrace(); } } fakeDarkSwitcher = !fakeDarkSwitcher; Toast.makeText(getActivity(), "??~", Toast.LENGTH_SHORT).show(); }