SimpleDateFormat is known to not be thread-safe, and it's instances must be either unique to each thread or otherwise be synchronized.
happened to me a while back. serge On Mar 16, 7:15 pm, Torgny <[email protected]> wrote: > Yeah, the code is in its own thread. It's in a class that is > instantiated in the thread. I tried added synchronized to the method > that generates the date, and so far I haven't seen it crash at all. > Will try with a loop as well. I am still a bit new to the whole Java > thing. > > On Mar 16, 6:42 pm, "carl.whalley" <[email protected]> > wrote: > > > Can you show the code? > > It sounds like the GET isn't relevant. Is your code in its own thread? > > If so is it synchronised? > > You should be able to write a test which iterates 1000 times just > > performing the format, and catch it. > > -- > > Android Academyhttp://www.androidacademy.com > > > On Mar 16, 6:31 pm, Torgny <[email protected]> wrote: > > > > In a couple of places in my application I format the date to send with > > > a GET request to an external API. Most of the time this works > > > excellently, but 1 out of a 1000 times this fails and crashes my > > > application/service. > > > > Here is the output the debugger gives me: > > > > Uncaught handler: thread Thread-9 exiting due to uncaught exception > > > java.lang.NullPointerException > > > at dalvik.system.PathClassLoader.findResource(PathClassLoader.java: > > > 227) > > > at java.lang.ClassLoader.getResource(ClassLoader.java:363) > > > at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:401) > > > at java.lang.ClassLoader.getSystemResourceAsStream > > > (ClassLoader.java:171) > > > at java.util.ResourceBundle$1.run(ResourceBundle.java:304) > > > at java.util.ResourceBundle$1.run(ResourceBundle.java:303) > > > at java.security.AccessController.doPrivilegedImpl > > > (AccessController.java:173) > > > at java.security.AccessController.doPrivileged > > > (AccessController.java:53) > > > at java.util.ResourceBundle.handleGetBundle(ResourceBundle.java: > > > 301) > > > at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:169) > > > at java.util.ResourceBundle.getBundle(ResourceBundle.java:109) > > > at java.util.Locale$1.run(Locale.java:806) > > > at java.util.Locale$1.run(Locale.java:805) > > > at java.security.AccessController.doPrivilegedImpl > > > (AccessController.java:173) > > > at java.security.AccessController.doPrivileged > > > (AccessController.java:53) > > > at java.util.Locale.getBundle(Locale.java:804) > > > at java.util.Currency.getInstance(Currency.java:100) > > > at java.text.DecimalFormatSymbols.<init>(DecimalFormatSymbols.java: > > > 73) > > > at java.text.NumberFormat.getInstance(NumberFormat.java:283) > > > at java.text.NumberFormat.getNumberInstance(NumberFormat.java:348) > > > at java.text.NumberFormat.getInstance(NumberFormat.java:279) > > > at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:128) > > > at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:121) > > > > I've tried several different approaches to this but never really > > > figured out if I am doing something wrong or if this is an actual bug > > > in the OS itself. Can someone please help me figure out what is going > > > on? > > > > Warm Regards, > > > Torgny --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

