Closed felipeska closed 7 years ago
@felipeska Are you trying to use the hosted Sentry at getsentry.com? Or your own instance?
@joshdholtz own instance :sunny:
@felipeska I have not personally tried that myself yet :grin: That is an odd stacktrace though. I can try and spin one up myself though next week. I sadly don't have time this week.
@felipeska Can you paste an example of what you are setting for your BASE_URL
and DSN
? Doesn't need to be your actually one but just so I can see the pattern.
yes:
public static final String BASE_URL = "http://sentryafls.noip.me:9000";
public static final String DSN = "http://314f0a13ad8d4d43b4e6a6feea7d5f3f:5a4fa23776b24a8f8d58b1459b8f9a59@sentryafls.noip.me:9000/2";
Awesome, thanks! I try to squeeze in some time tonight to see what's up
@joshdholtz Thanks!!! :metal:
@felipeska Hey, just wanted to let you know that I am taking a look at this now! I had to make the move from Eclipse to Android Studio so took a bit to get everything going again :grimacing:
@joshdholtz Thanks. Add: the onCreate
belongs to a class that inherits from Application
@felipeska I think I just sent a successful request to your Sentry instance :grin: Can you let me know when you get a chance? I think it said "Hey yo"
+1 I got same Exception when init sentry.
@QuadFlask I am not able to reproduce @felipeska's issue or the issue you are seeing :confused: Can you give send me example code that you are trying to use?
@joshdholtz I just code like @felipeska did. In Application which I extends Application class, and init at the onCraete() method. Could you add code that check file is exist at Sentry class line 586?
Same error here I only use `Sentry.init(this.getApplicationContext(), "https://xxxxxxxxx"); from getsentry
W/System.err(17327): java.io.FileNotFoundException: /data/data/com.example/files/unsent_requests: open failed: ENOENT (No such file or directory)
W/System.err(17327): at libcore.io.IoBridge.open(IoBridge.java:456)
W/System.err(17327): at java.io.FileInputStream.<init>(FileInputStream.java:76)
W/System.err(17327): at android.app.ContextImpl.openFileInput(ContextImpl.java:961)
W/System.err(17327): at android.content.ContextWrapper.openFileInput(ContextWrapper.java:176)
W/System.err(17327): at com.example.Sentry$InternalStorage.readObject(Sentry.java:584)
W/System.err(17327): at com.example.Sentry$InternalStorage.<init>(Sentry.java:540)
W/System.err(17327): at com.example.Sentry$InternalStorage.<init>(Sentry.java:526)
W/System.err(17327): at com.example.Sentry$InternalStorage$LazyHolder.<clinit>(Sentry.java:536)
W/System.err(17327): at com.example.Sentry$InternalStorage.getInstance(Sentry.java:532)
W/System.err(17327): at com.example.Sentry$InternalStorage.access$200(Sentry.java:526)
W/System.err(17327): at com.example.Sentry.sendAllCachedCapturedEvents(Sentry.java:188)
W/System.err(17327): at com.example.Sentry.setupUncaughtExceptionHandler(Sentry.java:156)
W/System.err(17327): at com.example.Sentry.init(Sentry.java:119)
W/System.err(17327): at com.example.Sentry.init(Sentry.java:107)
W/System.err(17327): at com.example.ScalaTestActivity.onCreate(ScalaTestActivity.scala:154)
W/System.err(17327): at android.app.Activity.performCreate(Activity.java:5990)
W/System.err(17327): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
W/System.err(17327): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
W/System.err(17327): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
W/System.err(17327): at android.app.ActivityThread.access$800(ActivityThread.java:151)
W/System.err(17327): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
W/System.err(17327): at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(17327): at android.os.Looper.loop(Looper.java:135)
W/System.err(17327): at android.app.ActivityThread.main(ActivityThread.java:5254)
W/System.err(17327): at java.lang.reflect.Method.invoke(Native Method)
I did include the lib into my own classes though
I think it's debug output.
Maybe someone can encapsulate it with a check if the file exists?
Yeah, you're right. It occurs only first time after installing application at
private ArrayList
@joshdholtz
I am experiencing the exact same problem in my application (using sentry-android-1.2.2):
03-08 09:41:55.996 2394-2394/*** W/System.err: java.io.FileNotFoundException: /data/data/***/files/unsent_requests: open failed: ENOENT (No such file or directory) 03-08 09:41:55.998 2394-2394/*** W/System.err: at libcore.io.IoBridge.open(IoBridge.java:456) 03-08 09:41:55.998 2394-2394/*** W/System.err: at java.io.FileInputStream.<init>(FileInputStream.java:76) 03-08 09:41:55.999 2394-2394/*** W/System.err: at android.app.ContextImpl.openFileInput(ContextImpl.java:961) 03-08 09:41:55.999 2394-2394/*** W/System.err: at android.content.ContextWrapper.openFileInput(ContextWrapper.java:176) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry$InternalStorage.readObject(Sentry.java:586) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry$InternalStorage.<init>(Sentry.java:542) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry$InternalStorage.<init>(Sentry.java:528) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry$InternalStorage$LazyHolder.<clinit>(Sentry.java:538) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry$InternalStorage.getInstance(Sentry.java:534) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry$InternalStorage.access$200(Sentry.java:528) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry.sendAllCachedCapturedEvents(Sentry.java:190) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry.setupUncaughtExceptionHandler(Sentry.java:158) 03-08 09:41:55.999 2394-2394/*** W/System.err: at com.joshdholtz.sentry.Sentry.init(Sentry.java:121)
So far, in a few cases it prevents my application from working properly, but most of the time it works. Can you please explain what impact this error can have on functionality of your library (Like what portion of your lib may not work in case of this error)? Any chance that this issue being resolved soon?
+1 I faced the same exception with my own sentry instance.
+1 Same problem with local Sentry, and not just on the first run.
I do have a local Sentry that I can spin up now so I will take a look this as soon as I can for you guys
@joshdholtz Thanks a lot.
I can't see how this issue is related to using local sentry instances (and may be unrelated), but the problem seems to be related to calling Sentry::InternalStorage::readObject
before any call to Sentry::InternalStorage::writeObject
. I think either this file is not created at all, or is not created in certain conditions.
Currently I am using this code before calling Sentry.init
to mitigate the problem:
try {
File unsetRequestsFile = new File(getFilesDir(), "unsent_requests");
if (!unsetRequestsFile.exists()) {
FileOutputStream fos = openFileOutput("unsent_requests", Context.MODE_PRIVATE);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(new ArrayList<Sentry.SentryEventRequest>());
oos.close();
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
And would recommend this patch to the InternalStorage
constructor:
private InternalStorage() {
Context context = Sentry.getInstance().context;
try {
File unsetRequestsFile = new File(getFilesDir(), FILE_NAME);
if (!unsetRequestsFile.exists()) {
writeObject(context, new ArrayList<Sentry.SentryEventRequest>());
}
} catch (IOException e) {
e.printStackTrace();
}
this.unsentRequests = this.readObject(context);
}
@amiraliakbari Thanks for the recommend patch! I haven't gotten a chance yet to test it with a local installation of Sentry but I don't see how this is related to a local installation of Sentry either.
What kind of device / OS are you running this on where you are seeing this? Or does it just not matter the device?
I have seen it on multiple devices/Android versions. Also it seems to be independent of using local Sentry instance. I think resource management in InternalStorage
class should be improved to solve this issue and possibly other related special cases.
Another recommended patch:
private ArrayList<SentryEventRequest> readObject(Context context) {
try {
FileInputStream fis = context.openFileInput(FILE_NAME);
ObjectInputStream ois = new ObjectInputStream(fis);
ArrayList<SentryEventRequest> requests = (ArrayList<SentryEventRequest>) ois.readObject();
+ ois,close();
+ fis,close();
return requests;
To remove this warning:
E/StrictMode: A resource was acquired at attached stack trace but never released.
See java.io.Closeable for information on avoiding resource leaks.
@amiraliakbari Good call on those closes :wink: I have no idea how those got missed :broken_heart:
Alright everyone (who is having this issue), if you could try this release to see if its fixes it, that would be great :blush:
compile 'com.joshdholtz.sentry:sentry-android:1.3.0'
I still can't reproduce so I hope this works :heart:
Closing this due to inactivity
init my sentry client:
anyone has a similar problem?