Skip to content

Commit

Permalink
Merge pull request #60 from joshdholtz/stop-leaking-credentials-warning
Browse files Browse the repository at this point in the history
Stop leaking credentials warning
  • Loading branch information
Josh Holtz authored Aug 4, 2016
2 parents 76f0363 + e2acf37 commit e718c07
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 21 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class MainActivity extends Activity {

Version | Changes
--- | ---
**1.4.3** | Fixes for a Google Play warning and added option to not use crash reporting (thanks to [ZeroStride](https://github.com/ZeroStride))
**1.4.1** | Fixes for a potential memory leak and a crash (thanks to [Syhids](https://github.com/Syhids) and [woostrowski](https://github.com/woostrowski))
**1.4.0** | Fixes issues when using self-hosted Sentry server
**1.2.1** | Sends up data to Sentry as UTF-8
Expand All @@ -48,7 +49,7 @@ Version | Changes
### Gradle
Available in jCenter
```
compile 'com.joshdholtz.sentry:sentry-android:1.4.1'
compile 'com.joshdholtz.sentry:sentry-android:1.4.3'
```

### Manual
Expand Down
2 changes: 1 addition & 1 deletion sentry-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ ext {
siteUrl = 'https://github.com/nuuneoi/FBLikeAndroid'
gitUrl = 'https://github.com/nuuneoi/FBLikeAndroid.git'

libraryVersion = '1.4.1'
libraryVersion = '1.4.3'

developerId = 'joshdholtz'
developerName = 'Josh Holtz'
Expand Down
5 changes: 4 additions & 1 deletion sentry-android/sentry-android.iml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":sentry-android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.joshdholtz.sentry" external.system.module.version="1.3.0" type="JAVA_MODULE" version="4">
<module external.linked.project.id=":sentry-android" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="com.joshdholtz.sentry" external.system.module.version="1.4.2" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
Expand Down Expand Up @@ -76,6 +76,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
Expand All @@ -88,7 +89,9 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
Expand Down
29 changes: 18 additions & 11 deletions sentry-android/src/main/java/com/joshdholtz/sentry/Sentry.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public class Sentry {
private Context context;

public static String sentryVersion = "7";
public static boolean debug = false;

private String baseUrl;
private String dsn;
Expand All @@ -107,6 +108,12 @@ private Sentry() {

}

private static void log(String text) {
if (debug) {
Log.d(TAG, text);
}
}

private static Sentry getInstance() {
return LazyHolder.instance;
}
Expand Down Expand Up @@ -163,7 +170,7 @@ private void setupUncaughtExceptionHandler() {

UncaughtExceptionHandler currentHandler = Thread.getDefaultUncaughtExceptionHandler();
if (currentHandler != null) {
Log.d("Debugged", "current handler class="+currentHandler.getClass().getName());
log("current handler class=" + currentHandler.getClass().getName());
}

// don't register again if already registered
Expand Down Expand Up @@ -206,7 +213,7 @@ private static String getProjectId() {

public static void sendAllCachedCapturedEvents() {
List<SentryEventRequest> unsentRequests = InternalStorage.getInstance().getUnsentRequests();
Log.d(Sentry.TAG, "Sending up " + unsentRequests.size() + " cached response(s)");
log("Sending up " + unsentRequests.size() + " cached response(s)");
for (SentryEventRequest request : unsentRequests) {
Sentry.doCaptureEventPost(request);
}
Expand Down Expand Up @@ -256,7 +263,7 @@ public static void captureUncaughtException(Context context, Throwable t) {

// Embed version in stacktrace filename
File stacktrace = new File(getStacktraceLocation(context), "raven-" + String.valueOf(random) + ".stacktrace");
Log.d(TAG, "Writing unhandled exception to: " + stacktrace.getAbsolutePath());
log("Writing unhandled exception to: " + stacktrace.getAbsolutePath());

// Write the stacktrace to disk
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(stacktrace));
Expand All @@ -269,7 +276,7 @@ public static void captureUncaughtException(Context context, Throwable t) {
ebos.printStackTrace();
}

Log.d(TAG, result.toString());
log(result.toString());
}

private static String getCause(Throwable t, String culprit) {
Expand Down Expand Up @@ -310,7 +317,7 @@ public static void captureEvent(SentryEventBuilder builder) {
request = new SentryEventRequest(builder);
}

Log.d(TAG, "Request - " + request.getRequestData());
log("Request - " + request.getRequestData());

// Check if on main thread - if not, run on main thread
if (Looper.myLooper() == Looper.getMainLooper()) {
Expand Down Expand Up @@ -426,15 +433,15 @@ protected Void doInBackground(Void... params) {
int projectId = Integer.parseInt(getProjectId());
String url = Sentry.getInstance().baseUrl + "/api/" + projectId + "/store/";

Log.d(TAG, "Sending to URL - " + url);
log("Sending to URL - " + url);

HttpClient httpClient;
if(Sentry.getInstance().verifySsl != 0) {
Log.d(TAG, "Using http client");
log("Using http client");
httpClient = new DefaultHttpClient();
}
else {
Log.d(TAG, "Using https client");
log("Using https client");
httpClient = getHttpsClient(new DefaultHttpClient());
}

Expand Down Expand Up @@ -484,7 +491,7 @@ protected Void doInBackground(Void... params) {

success = (status == 200);

Log.d(TAG, "SendEvent - " + status + " " + stringResponse);
log("SendEvent - " + status + " " + stringResponse);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
Expand Down Expand Up @@ -594,7 +601,7 @@ public List<SentryEventRequest> getUnsentRequests() {

public void addRequest(SentryEventRequest request) {
synchronized(this) {
Log.d(Sentry.TAG, "Adding request - " + request.uuid);
log("Adding request - " + request.uuid);
if (!this.unsentRequests.contains(request)) {
this.unsentRequests.add(request);
this.writeObject(Sentry.getInstance().context, this.unsentRequests);
Expand All @@ -604,7 +611,7 @@ public void addRequest(SentryEventRequest request) {

public void removeBuilder(SentryEventRequest request) {
synchronized(this) {
Log.d(Sentry.TAG, "Removing request - " + request.uuid);
log("Removing request - " + request.uuid);
this.unsentRequests.remove(request);
this.writeObject(Sentry.getInstance().context, this.unsentRequests);
}
Expand Down
14 changes: 7 additions & 7 deletions sentry-app/sentry-app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/builds" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protected void onCreate(Bundle savedInstanceState) {

String yourDSN = "your-dsn";
Sentry.init(this, yourDSN);
Sentry.debug = true;
Sentry.captureMessage("OMG this works woooo");
}

Expand Down

0 comments on commit e718c07

Please sign in to comment.