List of usage examples for java.lang RuntimeException fillInStackTrace
public synchronized Throwable fillInStackTrace()
From source file:org.safs.selenium.webdriver.lib.interpreter.WDTestRun.java
/** * Executes the next step. /*from www. ja v a 2 s .c om*/ * Extracts the Step and executes via runStep for enhanced * handling of some StepTypes. * @return True on success. * @see #runStep(Step) */ @Override public boolean next() { if (stepIndex == -1) { getLog().debug("Starting test run."); } initRemoteWebDriver(); getLog().debug("Running step " + (stepIndex + 2) + ":" + getScript().steps.get(stepIndex + 1).type.getClass().getSimpleName() + " step."); boolean result = runStep(getScript().steps.get(++stepIndex)); if (!result) { // If a verify failed, we just note this but continue. if (currentStep().type instanceof Verify) { getLog().error(currentStep() + " failed."); return false; } // In all other cases, we throw an exception to stop the run. RuntimeException e = new RuntimeException(currentStep() + " failed."); e.fillInStackTrace(); throw e; // continue? } else { return true; } }
From source file:org.safs.selenium.webdriver.lib.interpreter.WDTestRun.java
/** * Execute the action represented in the Step. * This does NOT change or increment any counters of what Step is being executed * in the Script./* w w w . ja v a2 s. co m*/ * <p> * If the StepType is an instanceof ClickElement we will use our own WDClickElement * which uses our enhanced WDLibrary to perform the click.<br> * * @param step * @return */ public boolean runStep(Step step) { initRemoteWebDriver(); try { StepType type = step.type; if (type instanceof ClickElement) { type = new WDClickElement(); } else if (type instanceof Get) { type = new WDGet(); } else if (type instanceof SwitchToFrame) { type = new WDSwitchToFrame(); } else if (type instanceof SwitchToFrameByIndex) { type = new WDSwitchToFrameByIndex(); } else if (type instanceof Store) { String varname = this.string("variable"); String text = this.string("text"); WebDriverGUIUtilities._LASTINSTANCE.getSTAFHelper().setVariable(varname, text); } return type.run(this); } catch (Throwable e) { this.log().debug("WDTestRun.runStep() " + e.getClass().getName() + ": " + e.getMessage(), e); RuntimeException t = new RuntimeException(currentStep() + " failed.", e); t.fillInStackTrace(); throw t; } }
From source file:android.content.BroadcastReceiver.java
void checkSynchronousHint() { if (mPendingResult == null) { throw new IllegalStateException("Call while result is not pending"); }/* w w w . j ava 2s . co m*/ // Note that we don't assert when receiving the initial sticky value, // since that may have come from an ordered broadcast. We'll catch // them later when the real broadcast happens again. if (mPendingResult.mOrderedHint || mPendingResult.mInitialStickyHint) { return; } RuntimeException e = new RuntimeException( "BroadcastReceiver trying to return result during a non-ordered broadcast"); e.fillInStackTrace(); Log.e("BroadcastReceiver", e.getMessage(), e); }
From source file:android.app.LoaderManager.java
void doStop() { if (DEBUG)/*from w w w.ja v a 2 s . co m*/ Log.v(TAG, "Stopping in " + this); if (!mStarted) { RuntimeException e = new RuntimeException("here"); e.fillInStackTrace(); Log.w(TAG, "Called doStop when not started: " + this, e); return; } for (int i = mLoaders.size() - 1; i >= 0; i--) { mLoaders.valueAt(i).stop(); } mStarted = false; }
From source file:android.app.LoaderManager.java
void doRetain() { if (DEBUG)/* w w w .j a v a 2 s . c o m*/ Log.v(TAG, "Retaining in " + this); if (!mStarted) { RuntimeException e = new RuntimeException("here"); e.fillInStackTrace(); Log.w(TAG, "Called doRetain when not started: " + this, e); return; } mRetaining = true; mStarted = false; for (int i = mLoaders.size() - 1; i >= 0; i--) { mLoaders.valueAt(i).retain(); } }
From source file:android.app.LoaderManager.java
void doStart() { if (DEBUG)/* ww w . j a v a 2s . co m*/ Log.v(TAG, "Starting in " + this); if (mStarted) { RuntimeException e = new RuntimeException("here"); e.fillInStackTrace(); Log.w(TAG, "Called doStart when already started: " + this, e); return; } mStarted = true; // Call out to sub classes so they can start their loaders // Let the existing loaders know that we want to be notified when a load is complete for (int i = mLoaders.size() - 1; i >= 0; i--) { mLoaders.valueAt(i).start(); } }
From source file:ed.net.httpclient.HttpConnection.java
public void go() throws IOException { boolean doIWantKeepAlive = true; _lastAccess = System.currentTimeMillis(); if (_sock == null) { int port = _currentUrl.getPort(); if (port < 0) { if (_currentUrl.getProtocol().equalsIgnoreCase("https")) port = 443;//from w ww .j av a 2s . c o m else port = 80; } if (DEBUG) LOGGER.debug("creating new socket to " + _key.getAddress()); InetSocketAddress isa = new InetSocketAddress(_key.getAddress(), port); _sock = new Socket(); _sock.connect(isa, _timeout); _sock.setSoTimeout(_timeout * 5); if (_currentUrl.getProtocol().equalsIgnoreCase("https")) { try { _sock = getDefaultSSLSocketFactory().createSocket(_sock, _currentUrl.getHost(), port, true); _usingSLL = true; doIWantKeepAlive = false; // don't trust this with SSL yet } catch (Exception e) { throw new RuntimeException(e); } } if (_sock == null) { RuntimeException re = new RuntimeException("_sock can't be null here. close called? " + _closed); re.fillInStackTrace(); LOGGER.error("weird...", re); throw re; } if (_sock.getInputStream() == null) throw new RuntimeException("_sock.getInputStream() is null!!"); // should never happen, should be IOException _in = new BufferedInputStream(_sock.getInputStream()); } StringBuilder buf = new StringBuilder(); // First Line buf.append(_requestMethod).append(" "); String f = _currentUrl.getFile(); if (f == null || f.trim().length() == 0) f = "/"; buf.append(f.replace(' ', '+')); buf.append(" HTTP/1.1\r\n"); for (Iterator i = _headers.keySet().iterator(); i.hasNext();) { String name = (String) i.next(); String value = String.valueOf(_headers.get(name)); buf.append(name).append(": ").append(value).append("\r\n"); if (name.equalsIgnoreCase("connection") && value.equalsIgnoreCase("close")) doIWantKeepAlive = false; } buf.append("\r\n"); String headerString = buf.toString(); if (DEBUG) System.out.println(headerString); try { _sock.getOutputStream().write(headerString.getBytes()); if (_postData != null) _sock.getOutputStream().write(_postData); int timeoutSeconds = 60; _timeOutKeeper.add(this, timeoutSeconds); _in.mark(10); if (_in.read() < 0) throw new IOException("stream closed on be ya bastard"); _in.reset(); if (DEBUG) System.out.println("sent header and seems to be ok"); } catch (IOException ioe) { if (_keepAlive) { if (DEBUG) LOGGER.debug("trying again"); // if we previously had a keep alive connection, maybe it died, so rety _keepAlive = false; _key.reset(); close(); reset(_currentUrl, false); go(); return; } throw ioe; } // need to look for end of headers byte currentLine[] = new byte[2048]; int idx = 0; boolean gotStatus = false; boolean chunked = false; int lineNumber = 0; boolean previousSlashR = false; while (true) { if (idx >= currentLine.length) { byte temp[] = new byte[currentLine.length * 2]; for (int i = 0; i < currentLine.length; i++) temp[i] = currentLine[i]; currentLine = temp; } int t = -1; try { t = _in.read(); } catch (NullPointerException e) { throw new IOException("input stream was closed while parsing headers"); } if (t < 0) throw new IOException("input stream got closed while parsing headers"); currentLine[idx] = (byte) t; if (currentLine[idx] == '\r') { currentLine[idx] = ' '; } else if (currentLine[idx] == '\n') { String line = new String(currentLine, 0, idx).trim(); if (DEBUG) System.out.println(line); if (line.length() == 0) { if (DEBUG) System.out.println("rc:" + _rc); if (_rc == 100) { if (DEBUG) System.out.println("got Continue"); gotStatus = false; lineNumber = 0; idx = 0; continue; } break; } if (!gotStatus) { gotStatus = true; Matcher m = STATUS_PATTERN.matcher(line); if (!m.find()) throw new IOException("invalid status line:" + line); _httpVersion = Double.parseDouble(m.group(1)); _rc = Integer.parseInt(m.group(2)); _message = m.group(3); _responseHeaderFields[0] = line; } else { int colon = line.indexOf(":"); if (colon < 0) { //throw new IOException("invalid header[" + line + "]"); LOGGER.error("weird error : {" + line + "} does not have a colon, using the whole line as the value and SWBadHeader as the key"); line = "SWBadHeader:" + line; colon = line.indexOf(":"); } String name = line.substring(0, colon).trim(); String value = line.substring(colon + 1).trim(); _responseHeaders.put(name, value); if (name.equalsIgnoreCase("Transfer-Encoding") && value.equalsIgnoreCase("chunked")) chunked = true; if (lineNumber >= (_responseHeaderFields.length - 2)) { // need to enlarge header... String keys[] = new String[_responseHeaderFieldKeys.length * 2]; String values[] = new String[_responseHeaderFields.length * 2]; for (int i = 0; i < lineNumber; i++) { keys[i] = _responseHeaderFieldKeys[i]; values[i] = _responseHeaderFields[i]; } _responseHeaderFieldKeys = keys; _responseHeaderFields = values; } _responseHeaderFieldKeys[lineNumber] = name; _responseHeaderFields[lineNumber] = value; } if (DEBUG) System.out.println( "\t" + _responseHeaderFieldKeys[lineNumber] + ":" + _responseHeaderFields[lineNumber]); lineNumber++; idx = -1; } idx++; } _responseHeaderFieldKeys[lineNumber] = null; _responseHeaderFields[lineNumber] = null; // TODO: obey max? etc...? _keepAlive = false; if (doIWantKeepAlive && (chunked || getContentLength() >= 0 || _rc == 304)) { String hf = null; if (hf == null) hf = "Connection"; if (_httpVersion > 1) { _keepAlive = getHeaderField(hf) == null || getHeaderField(hf).toLowerCase().indexOf("close") < 0; } else { _keepAlive = getHeaderField(hf) != null && getHeaderField(hf).toLowerCase().indexOf("keep-alive") >= 0; } } if (DEBUG) System.out.println("_keepAlive=" + _keepAlive); /* DM: TODO -------------------------------- fix keepalive it's not set if no content length */ if (!_requestMethod.equals("HEAD")) { if (chunked) { _userIn = new ChunkedInputStream(_in); } else if (_keepAlive || _usingSLL) { _userIn = new MaxReadInputStream(_in, getContentLength()); } else { _userIn = _in; // just pass throgh } } _lastAccess = System.currentTimeMillis(); }
From source file:edu.stanford.muse.util.Util.java
public static void ASSERT(boolean b) { if (!b) {/*from w w w.ja va 2 s .c om*/ System.err.println("Assertion failed!\n"); RuntimeException re = new RuntimeException(); re.fillInStackTrace(); print_exception("Assertion failed", re, null /* log */); throw re; } }