List of usage examples for java.lang Throwable Throwable
public Throwable()
From source file:org.apache.hadoop.hdfs.AvatarClient.java
private int deleteUsingTrash(String file, boolean recursive) throws IOException { // The configuration parameter specifies the class name to match. // Typically, this is set to org.apache.hadoop.fs.FsShell.delete String className = conf.get("fs.shell.delete.classname"); if (className == null) { className = "org.apache.hadoop.fs.FsShell.delete"; }/*w ww. ja va 2s .c o m*/ // find the stack trace of this thread StringWriter str = new StringWriter(); PrintWriter pr = new PrintWriter(str); try { throw new Throwable(); } catch (Throwable t) { t.printStackTrace(pr); } // if the specified class does not appear in the calling thread's // stack trace, and if this file is not in "/tmp", // then invoke FsShell.delete() if (str.toString().indexOf(className) == -1 && file.indexOf("/tmp") != 0) { String errmsg = "File " + file + " is beng deleted only through Trash " + className + " because all deletes must go through Trash."; LOG.warn(errmsg); FsShell fh = new FsShell(conf); Path p = new Path(file); fh.init(); try { fh.delete(p, p.getFileSystem(conf), recursive, false); return 0; // successful deletion } catch (RemoteException rex) { throw rex.unwrapRemoteException(AccessControlException.class); } catch (AccessControlException ace) { throw ace; } catch (IOException e) { return 1; // deletion unsuccessful } } return -1; // deletion not attempted }
From source file:org.eclipse.epp.internal.logging.aeri.ui.LogListenerTest.java
@Test public void testSkipSimilarErrors() { settings.setSkipSimilarErrors(true); Throwable t1 = new Throwable(); Status s1 = new Status(IStatus.ERROR, TEST_PLUGIN_ID, "test message", t1); Status s2 = new Status(IStatus.ERROR, TEST_PLUGIN_ID, "test message", t1); sut.logging(s1, ""); NewReportLogged event1 = pollEvent(1, TimeUnit.SECONDS); history.remember(event1.report);/* w w w . ja v a2 s . c o m*/ sut.logging(s2, ""); NewReportLogged event2 = pollEvent(1, TimeUnit.SECONDS); assertThat(event2, is(nullValue())); }
From source file:org.eclipse.rdf4j.repository.http.HTTPRepositoryConnection.java
@Override public void close() throws RepositoryException { if (isActive()) { logger.warn("Rolling back transaction due to connection close", new Throwable()); rollback();//from w w w. j a v a 2 s. c om } super.close(); }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Throwing.// ww w .j av a2 s .co m * * @param thrown The instance of <code>Throwable</code> * @see java.util.logging.Level#SEVERE */ public void throwing(Throwable thrown) { StackTraceElement[] elements = new Throwable().getStackTrace(); throwing(elements[1].getClassName(), elements[1].getMethodName(), thrown); }
From source file:mobisocial.socialkit.musubi.Musubi.java
public DbIdentity userForLocalId(Uri feedUri, long localId) { DbIdentity cachedUser = sUserCache.get(localId); if (cachedUser != null) { return cachedUser; }//from w ww . j a va 2s . c o m String feedName; if (feedUri != null) { feedName = feedUri.getLastPathSegment(); } else { feedName = "friend"; } Uri uri = uriForItem(DbThing.IDENTITY, localId); String[] projection = { DbIdentity.COL_ID_HASH, DbIdentity.COL_NAME }; String selection = DbIdentity.COL_IDENTITY_ID + " = ?"; String[] selectionArgs = new String[] { Long.toString(localId) }; String sortOrder = null; Cursor c = mContext.getContentResolver().query(uri, projection, selection, selectionArgs, sortOrder); if (c == null) { Log.w(Musubi.TAG, "Null cursor for user query " + localId); return null; } try { if (!c.moveToFirst()) { Log.w(Musubi.TAG, "No user found for " + localId + " in " + feedName, new Throwable()); return null; } DbIdentity user = DbIdentity.fromStandardCursor(mContext, c); sUserCache.put(localId, user); return user; } finally { c.close(); } }
From source file:com.jsonstore.database.WritableDatabase.java
public int update(JSONObject newObj, boolean markDirty) throws Throwable { long dirtyTime = (markDirty ? new Date().getTime() : 0); int id = newObj.getInt(DatabaseConstants.FIELD_ID); Map<String, Object> mappedObj; String operation;//from www.j av a2s . c o m HashMap<String, Object> whereClauses = new HashMap<String, Object>(); // TODO: Verify that this *really* does *always* have an _id present. If not, this will fail ugly. // The object passed in is actually of the form { _id:, json: }. // The object in the json field is the one we really want to update // with. newObj = newObj.getJSONObject(DatabaseConstants.FIELD_JSON); mappedObj = getSchema().mapObject(newObj, null); // Add in all the stuff to indicate that the object has been // replaced. mappedObj.put(DatabaseConstants.FIELD_DIRTY, dirtyTime); mappedObj.put(DatabaseConstants.FIELD_ID, id); mappedObj.put(DatabaseConstants.FIELD_JSON, newObj.toString()); // See if this object's operation was previously "add". If so, we // don't want to update the operation. operation = findOperationForObjectById(id); //TODO: Is operation_remove necessary here? if ((operation == null) || operation.equals(DatabaseConstants.OPERATION_REMOVE)) { // We're either replacing a non-existent record or trying to update something that's // removed, so abort. throw new Throwable(); } if (!operation.equals(DatabaseConstants.OPERATION_ADD)) { mappedObj.put(DatabaseConstants.FIELD_OPERATION, DatabaseConstants.OPERATION_REPLACE); } whereClauses.put(DatabaseConstants.FIELD_ID, id); return update(mappedObj, whereClauses); }
From source file:org.eclipse.epp.internal.logging.aeri.ui.LogListenerTest.java
@Test public void testNoSkippingSimilarErrors() { settings.setSkipSimilarErrors(false); Throwable t1 = new Throwable(); Status s1 = new Status(IStatus.ERROR, TEST_PLUGIN_ID, "test message", t1); Status s2 = new Status(IStatus.ERROR, TEST_PLUGIN_ID, "test message", t1); sut.logging(s1, ""); NewReportLogged event1 = pollEvent(); history.remember(event1.report);//from ww w . java 2s .c o m sut.logging(s2, ""); NewReportLogged event2 = pollEvent(); assertThat(event2, is(not(nullValue()))); }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Debug./*from w w w .j a v a2 s . c o m*/ * * @param msgs the msgs * @see java.util.logging.Level#FINE */ public void debug(Object... msgs) { StackTraceElement[] elements = new Throwable().getStackTrace(); logp(Level.FINE, elements[1].getClassName(), elements[1].getMethodName(), StringUtil.toString(msgs)); }
From source file:org.ebayopensource.turmeric.eclipse.core.logging.SOALogger.java
/** * Entering./*from www . j a v a 2s . c o m*/ * * @param params The multiple parameters that passed in * @see java.util.logging.Level#FINER */ public void entering(Object... params) { StackTraceElement[] elements = new Throwable().getStackTrace(); if (params != null) entering(elements[1].getClassName(), elements[1].getMethodName(), params); else entering(elements[1].getClassName(), elements[1].getMethodName()); }
From source file:mobisocial.socialkit.musubi.Musubi.java
/** * Returns the DbUser that is currently logged in to this app. *///ww w. j a v a 2s . co m public DbIdentity userForLocalDevice(Uri feedUri) { Uri uri; if (feedUri == null) { uri = uriForDir(DbThing.IDENTITY); } else { long feedId = ContentUris.parseId(feedUri); uri = uriForItem(DbThing.MEMBER, feedId); } String selection = DbIdentity.COL_OWNED + " = 1"; String[] selectionArgs = null; String sortOrder = null; Cursor c = mContext.getContentResolver().query(uri, DbIdentity.COLUMNS, selection, selectionArgs, sortOrder); try { if (c == null || !c.moveToFirst()) { Log.w(TAG, "no local user for feed " + feedUri, new Throwable()); return null; } DbIdentity id = DbIdentity.fromStandardCursor(mContext, c); return id; } finally { if (c != null) { c.close(); } } }