exception

Is it safe to store an instance of an Exception and reuse it?

大憨熊 提交于 2020-01-14 07:13:52
问题 Is it safe to: public class Widget { private static final IllegalStateException LE_EXCEPTION = new IllegalStateException("le sophisticated way"); ... public void fun() { // some logic here, that may throw throw LE_EXCEPTION; } .... } keep an instance of an exception use it whenever needed (throw) instead of throwing a new exception each time? I am interested if it's safe By safe I mean: no memory corruption, no additional exceptions thrown by JVM, by missing classes, no bad classes loaded (..

.Jar file runs in netbeans but not when opened outside

倖福魔咒の 提交于 2020-01-14 06:13:42
问题 I have looked at: why doesn't my jar file run outside netbeans? and believe I am getting the same problem. The program runs fine in netbeans but doesnt appear when run on the outside. If i go into my task manager I can see that the program is being run. I had my program set up as a java web start app, but then i changed back to a .jar, because no website had big enough space to host it. I believe this may be the root cause of the problem. That, and when i reassigned my resources to be

.Jar file runs in netbeans but not when opened outside

被刻印的时光 ゝ 提交于 2020-01-14 06:13:33
问题 I have looked at: why doesn't my jar file run outside netbeans? and believe I am getting the same problem. The program runs fine in netbeans but doesnt appear when run on the outside. If i go into my task manager I can see that the program is being run. I had my program set up as a java web start app, but then i changed back to a .jar, because no website had big enough space to host it. I believe this may be the root cause of the problem. That, and when i reassigned my resources to be

StaleStateException while deleting through hibernate

霸气de小男生 提交于 2020-01-14 05:01:10
问题 I tried out hibernate mapping for domain classes in my application- which are Book,Author and Publisher.I wanted to remove a Publisher or Author who has no Books.So,I coded the logic for adding/deleting a Book as below. Deleting a book checks the size of Set of Books in Author and Publisher.If they contain only the single book instance(which is going to be deleted) ,the Author and Publisher are deleted.Else the book is removed from their Sets of Book. In my program,I put the codeblock for

__autoload fails to throw an Exception when it fails to load a class on a static method call

不羁的心 提交于 2020-01-14 03:59:08
问题 While attempting to implement some kind of error handling when my __autoload() function fails to load a file I stumbled upon this little 'oddity'. According to http://nl.php.net/autoload Exceptions thrown from within the __autoload() function can be caught in a catch block since PHP version 5.3+. Note: Prior to 5.3.0, exceptions thrown in the __autoload function could not be caught in the catch block and would result in a fatal error. From 5.3.0+ exceptions thrown in the __autoload function

What Exception is thrown on timeout?

萝らか妹 提交于 2020-01-14 03:56:10
问题 What Exception is thrown on connection timeout in HTMLUnit ? 回答1: HtmlUnit uses the Apache HttpClient. The timeout mechanism throws an InterruptedIOException. See the HttpClient documentation. This exception is a subclass of IOException, which can be thrown during any HttpClient execute call (basically whenever you get a page with an HtmlUnit WebClient. 回答2: I think there is a bug, it really should throw a exception but dont throw if you set an timeout great than a value, you can see it in

App crashes when started again for a second time

萝らか妹 提交于 2020-01-14 03:31:09
问题 I am currently porting an Iphone app to Android and as I had no clue of fragments I thought I gonna try it with them, so I created several classes (one for each view thats presented to the user, all extending baseclass Fragment) and the respective xml layouts. Code below for the fragment that's shown on launch. I use a singleton for every fragment. public class FragWelcome extends Fragment { private static FragWelcome _fs; OnClickListener mListener; public FragWelcome() {} public static

Android: Video-streaming with Mediarecorder over Sockets using ParcelFileDescriptor

对着背影说爱祢 提交于 2020-01-14 02:43:13
问题 I'm struggling with this quiet long and I decided I need help. The basis idea is described here: Link I want to stream the output from the MediaRecorder directly to my Server over Sockets while recording. (In this specific case I want to see if this is possible without using any streaming protocol just via a HTTP-POST.) The error of my current approach is: E/MediaRecorder: start failed: -2147483648 - RuntimeException Before I had an error pointing me to this topic mediarecorder-issue-on

Unhandled DivideByZero exception from an external DLL - C#

旧巷老猫 提交于 2020-01-13 19:20:09
问题 I have a C# (.net 4.0) program, whose main is calling methods from an external FTP library - a dll the project references. The logic is in a try-catch block, and the catch prints the error. The exception handler has a generic parameter: catch(Exception ex) . The IDE is VS. Sometimes the FTP library throws the following division by zero exception. The problem is it is not caught in the catch block, and the program crashes. Exceptions originated in my wrapper code are caught. Anyone has any

I keep getting java.io.NotSerializableException: java.io.ObjectOutputStream

走远了吗. 提交于 2020-01-13 17:03:47
问题 This is the code that I have been trying import java.util.Scanner; import java.io.*; abstract class Account implements Serializable { protected String accountHolderName; protected long balance; protected ObjectOutputStream accData; Scanner input = new Scanner(System.in); } class Savings extends Account implements Serializable { Savings() throws IOException { System.out.print("enter your name: "); accountHolderName = input.nextLine(); System.out.print("\n"); System.out.print("enter your