Hello,
I have a request for improvement in the area of backuping.
For catching the exceptions during online backups, I am using the solution suggested in the post 2786
Well not exactly, because there is written to use Thread.setDefaultUncaughtExceptionHandler() which is a global handler for all threads of the JVM and it is already used for other purpose in our app, so we are using the following solution:
Thread backupThread = backupQuery.getSingleResult(); backupThread.setUncaughtExceptionHandler((t, e) -> { // handle the exception in the way we would like }); // Wait until the backup is completed. try { backupThread.join(); } catch (InterruptedException e) { e.printStackTrace(); }
But it does not work well. For small database files in cases the exception is risen in the beginning of the backup process, then the backupThread finished its work even before our code would set the exception handler on the backupThread object.
So we lose the exception and our backup process acts as it would have run fine.
However the backupThread object has the exception stored in itself in field 'a', like u can see on the attached screen.
So my suggestion is that You could either make this field accessible via some API or the
TypedQuery.getSingleResult()
would accept a parameter of type
UncaughtExceptionHandler
which would be set on the executing thread before the execution starts.
That way we would not lose the exceptions in the beginning of the backuping.