When the Worker.State FAILED occurs in a Task?

How to detect that a Worker.State FAILED occurs in a Task? or to say when the Worker.State FAILED occurs in a Task? Is it when an exception happens in the call() method of Task?
Consider the code below:
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
import javafx.concurrent.Task;
* Background task to fetch the all classes documentation page from a URL
public class FetchDocListTask extends Task<String> {
  private final String docsDirUrl;
  public FetchDocListTask(String docsDirUrl) {
  this.docsDirUrl = docsDirUrl;
  @Override
  protected String call() throws Exception {
  System.out.println("---- FetchDocListTask  docsUrl = " + docsDirUrl);
  StringBuilder builder = new StringBuilder();
  try {
  URI uri = new URI(docsDirUrl + "allclasses-frame.html");
  URL url = uri.toURL();
  URLConnection urlConnection = url.openConnection();
  urlConnection.setConnectTimeout(5000); // set timeout to 5 secs
  InputStream in = urlConnection.getInputStream();
  BufferedReader reader = new BufferedReader(
  new InputStreamReader(in));
  String line;
  while ((line = reader.readLine()) != null) {
  builder.append(line);
  builder.append('\n');
  reader.close();
  } catch (URISyntaxException e) {
  e.printStackTrace();
  return builder.toString();
When the State.FAILED occurs? In fact, I want to write a code to simply detect whether the computer is connected to the internet. Hope for help~

Yes. If the call() method exits due to an unhandled exception, the state property changes to FAILED. If a return statement is successfully executed, the state property changes to SUCCEEDED. There are no other possibilities.
You can test with something like:
import javafx.application.Application;
    import javafx.concurrent.Task;
    import javafx.concurrent.WorkerStateEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.TextArea;
    import javafx.scene.layout.BorderPane;
    import javafx.stage.Stage;
    public class TaskStateTest extends Application {
        public static void main(String[] args) { launch(args); }
        @Override
        public void start(final Stage primaryStage) {
            Task<Void> exceptionHandlingTask = new Task<Void>() {
                @Override
                protected Void call() throws Exception {
                    try {
                        throw new Exception("Boom");
                    } catch (Exception exc) {
                        System.out.println(exc.getMessage() + " handled");
                    return null;
            Task<Void> exceptionThrowingTask = new Task<Void>() {
                @Override
                protected Void call() throws Exception {
                    throw new Exception("Boom");
        //            return null;
            final BorderPane root = new BorderPane();
            final TextArea textArea = new TextArea();
            root.setCenter(textArea);
            primaryStage.setScene(new Scene(root, 600, 400));
            primaryStage.show();
            registerHandlers(exceptionHandlingTask, "exceptionHandlingTask", textArea);
            registerHandlers(exceptionThrowingTask, "exceptionThrowingTask", textArea);
            Thread t1 = new Thread(exceptionHandlingTask);
            Thread t2 = new Thread(exceptionThrowingTask);
            t1.start();
            t2.start();
        private void registerHandlers(final Task<Void> task, final String msg, final TextArea textArea) {
            task.setOnFailed(new EventHandler<WorkerStateEvent>() {
                @Override
                public void handle(WorkerStateEvent event) {
                    textArea.appendText(msg + " failed\n");
            task.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
                @Override
                public void handle(WorkerStateEvent event) {
                    textArea.appendText(msg +  " succeeded\n");

Similar Messages

  • When the update statement will check the constraint violation ?

    Hello all,
    i am working on data masking of production data using oracle Translate function.i have created a function otis_mask using translate function to mask sensitive values .For this i am tesitng on a small table. i have created a table with single primary key column SSN.
    sql>desc SSN_MASK
    Name Null? Type
    SSN NOT NULL NUMBER(10)
    1) i have inserted the value 9949577766. if resulted mask value exist in table it should throw the constraint violation error.But it is not throwing any error.rows are properly updating .
    Eg:-
    Table contains below values.
    PA_DATA_SUB @qdsrih30 >select *from SSN_MASK;
    SSN
    7727399911
    9949577766
    9989477700
    UPDATE SSN_MASK SET SSN=otis_mask(SSN);
    if above update statement process 7727399911 first then resulted mask value is 9989477700.This value is already in the table.
    if the update statement process 9949577766 first then resulted mask value is 7727399911.This value is already in the table.
    in any of the above scenario update statement should have to throw constraint violation error. But its not happening. rows are properly updating . when the update statement checking the constraint violation ? after processing all the rows or processing of each row ?
    Please help me in understandding the update statement processing ?
    Thanks,
    Venkat Vadlamudi.

    1)created a function as below.
    CREATE OR REPLACE Function otis_mask(incol varchar2) return varchar2 is
    random_str varchar2(20);
    begin
    select (translate(incol,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890','qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0842319576')) INTO random_str FROM DUAL;
    return random_str;
    end;
    2. create a table ssn_mask.
    create table ssn_mask(ssn number(10) primary key);
    3) inserted 3 rows as below.
    insert into ssn_mask values(9949577766);
    insert into ssn_mask values(7727399911);
    insert into ssn_mask values(9989477700);
    4)UPDATE SSN_MASK SET SSN=otis_mask(SSN);
    5) Table contains below rows.
    Sql >select *from SSN_MASK;
    SSN
    9949577766
    7727399911
    9989477700.
    6)UPDATE SSN_MASK SET SSN=otis_mask(SSN);
    If the above statement process first row 9949577766,then otis_mask function will return 7727399911 and update statement will update the value of 9949577766 to 7727399911 .At this case 7727399911 is already in the table.So update statement should have to throw primary key constraint violation error.
    If the above statement process second row 7727399911 first ,then otis_mask function will return 9989477700.and update statement will update the value of 7727399911 to 9989477700.At this case 9989477700 is already in the table.So update statement should have to throw primary key constraint violation error.
    But its not throwing any integrity constraint violation error.
    i just want to know when update statement will check the constraint ?
    is update statement will first process all records and kepp in handy the new values then update the table with new values (or) process the first row and update the new value with old value then process second row and update with new value so on ?
    Thanks,
    Venkat Vadlamudi.

  • BCP to pass an Error Message to SSIS when the BCP call fails?

    Hi,
    Within SSIS I have an Execute SQL Task which calls BCP via a source variable given the dynamic nature of the BCP call.
    When the BCP call fails it returns a number of records which give instructions on how to use BCP. SSIS then thinks that BCP has executed successfully, the component shows green and then the package continues to run.
    But of course what I want the BCP call to do is return an error message which would then trigger the standard on error event handler within SSIS. How do I do this please?
    It maybe the “Execute Process Task” could be a better SSIS component to use for this call
    Using BCP Utility in SSIS. Does anyone have experience of doing this type of thing?
    Thanks in advance,
    Kieran.
    Kieran Patrick Wood http://www.innovativebusinessintelligence.com http://uk.linkedin.com/in/kieranpatrickwood http://kieranwood.wordpress.com/

    Why don't you use the "Fast Load" option = BULK LOAD? Or the BULK LOAD stored proc?
    The only other way I can think of this can be done is by directing errors to an error file which can be interrogated from the package and then a precedence constraint used to trigger an error if there was one.
    Arthur My Blog

  • How To Insert a Row If The Update Statement Fails?

    Hi folks,
    For some reason I just can't get this working and wanted to throw it out to everyone, very simple one so won't take much of your time up.
    Going through each row of the cursor, and wanting to update a table, if the record doesn't exist, then I want to insert it.....but nothing is happening.
    IF v_related_enrolement < 1
    THEN
    BEGIN
    -- Record NOT found in Study_block_associations
    -- Insert Student record into ADM_EVER_REGISTERED table
    -- Set Ever_Registered column to 'N'
    UPDATE adm_ever_registered
    SET ever_registered = 'N'
    WHERE personal_id = v_personal_id
    AND appl_code = v_appl_code;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    INSERT INTO adm_ever_registered VALUES(v_personal_id, v_appl_code, v_choice_no, 'N');
    END;
    ELSE

    It's better to use a merge statement in this case.
    Your code doesn't work because of the false assumption that an update statement that doesn't update a single row fails with a no_data_found exception, where it's a successful update statement that just doesn't update a single row. So instead of the exception, use a "if sql%rowcount = 0 then" construct to make your current code work. Best option, as said, is to switch to the merge statement.
    Regards,
    Rob.

  • HT3302 The very bottom of the touch screen on my iPhone does not respond to touch. When the touch screen fails, is is expensive to replace?

    Recently, the bottom edge of the touch screen on my iPhone stopped responding to touch. I have gone through all of your hints and tips in the service information pages to see if there was a DIY solution. The little 'dots' which indicate water damage are white. I checked those in case someone else had caused water damage to my phone, as I do not live alone. The home button works fine, the non-functioning area of the screen prevents me from using all functions for which the screen will not revolve to the side when the phone is tipped.  Texting is a nightmare, as I have to keep turning the phone to access certain alphnumeric icons on the keyboard. Is this a common problem with the iPhone 4? Is is expensive to repair?

    Before you claim the hardware failed, try basic troubleshooting as described in the User's Guide of reset, restart, restore (first from backup then as new).
    If none of these resolve the issue, Apple offers and Out of Warranty replacement for $149US.

  • "A connection to the server has failed" occurs in 3 minitues

    I have deployed a web application(ADF) that inserts batch of records(over 50k) to the DB and client is expected to wait for the response.
    But after client invoke the insert browser produce "A connection to the server has failed" java script error exactly after 3 minutes.
    So the connection between client and Web Logic 10.3 is failing. Insert to DB continues to work.
    Is this due to a timeout, why this error comes? How to configure web logic to avoid this.
    -Prasad

    PR,
    You've been given some advice on the ADF forum in terms of how to deal with this (e.g., make the process asynchronous and use an af:poll/af:progressBar to keep the user informed).
    Expecting a single HTTP request to work without timing out when you insert 50,000 rows one-by-one into the database is unrealistic.
    John

  • Event ID 2776 The worker process failed to initialise correctly and therefore could not be started

    Hi All,
    I'm getting the dreaded 503 Service Unavailable error on a freshly installed instance of SharePoint 2013 Foundation on a 2008 Server.
    I get this error when I try opening the Central Administration Console.
    It would appear that the worker process for the Central Administration console is crashing.
    In the System event log, I see a stack of 5009 Errors:
    Event Id 5009, WAS
    A process serving application pool 'SharePoint Central Administration V4' has terminated unexpectedly.
    Then I get an error:
    Event id 5009, WAS
    Application pool 'SharePoint Central Administration V4' is being automatically disabled due to a series of failures.
    What I see:
    In IIS, Both these application pools have stopped:
    SharePoint Central Administration v4
    SecurityTokenServiceApplicationPool
    If I start them up, then try accessing the Central Administration portal in IE, I get a 503 error, Service Unavailable
    When I check out the pools in IIS Manager, both pools have stopped.
    What I've tried:
    Ensured the password Identity is correct for each pool (the one that was used during the install, DB Account)
    Ensured that 32 bit Applications are disabled for both Application pools
    Ensured that the DB Account user has the following policy rights:
    Logon as a service
    Logon as a batch job
    Replace a process level token
    Any other ideas?
    Thanks
    Jason

    HI Jason,It seems that the issue is with the application pool only.make sure that the application pool is started and set with the correct credentials.please check the links below that explains more details of the issues.
    http://expertsharepoint.blogspot.de/2013/11/error-application-pool-keeps-stopping.html
    http://expertsharepoint.blogspot.de/2013/11/error-application-pool-keeps-stopping.html
    Anil Avula[Partner,MCP,MCSE,MCSA,MCTS,MCITP,MCSM] See Me At: http://expertsharepoint.blogspot.de/

  • No Withholding tax calculated when the work area is changed

    Hi All
    I have changed the work area in infotype 208 for an employee from OH to IL. Then i ran the payroll, but no withholding tax for IL was calculated. The employee residence area is IN.
    Any inputs on why its not calculated ?
    Regards
    Vamsi

    Hello Yogesh,
    Thanks for your reply!!!
    We have solved the issue.
    the issue is really due to after 7.3 Upgradation the RSPC_MONITOR had two more new feilds added
    1) UNAME & 2) CHECK_TIME
    and this fields doesn't exist in the 7.0 Version so due to this inconsistancy the Structure was failing.
    so we have included two new Fields in the structure in the program and in the Customer Exit and working fine now.
    With Regards,
    PJ.

  • PRI is not down when the MGCP VG fails to talk with CCM

    I got a MGCP voice gateway with PRI line registered to CCM. When I disconnected the voice gateway from the network, I found that the layer 3 (q.931) of PRI is still up.
    Just wonder if there's any command to bring the PRI down when the MGCP VG is out sync with the CCM?
    If there's no such configuration, then it seems that all incoming call will continue to send to the failure PRI line from PSTN.

    The IOS version 12.4(13r). There's nothing happened after all CCM servers are disconnected from the network.
    Below please find the capture -
    CCM#show ccm-manager
    MGCP Domain Name: CCM
    Priority Status Host
    =============================================
    Primary Down 192.168.3.125
    First Backup Down 192.168.3.126
    Second Backup None
    CCM#show isdn status
    Global ISDN Switchtype = primary-4ess
    ISDN Serial0/1/0:23 interface
    dsl 0, interface ISDN Switchtype = primary-4ess
    Layer 1 Status:
    ACTIVE
    Layer 2 Status:
    TEI = 0, Ces = 1, SAPI = 0, State = MULTIPLE_FRAME_ESTABLISHED
    Layer 3 Status:
    0 Active Layer 3 Call(s)
    Active dsl 0 CCBs = 0
    The Free Channel Mask: 0x807FFFFF
    Number of L2 Discards = 0, L2 Session ID = 9
    Total Allocated ISDN CCBs = 0
    CCM#

  • B1 Query returning truncated decimal places when the CASE statement is used

    Hi All,
    Perhaps this is a friday thing.
    In B1 the price setting is for 5 decimal places. I have a query the run a business process looking at the data in the Special Prices Tables. When I run the Query in SQL, the output show the correct number of decimal places. However, when the Query is then  saved and run in B1, the output is truncated to 2 decimal places. Any ideas as to how I can prevent this for happening?
    T0: Points to teh OSPP Table
    T1: Points to the OSP1 Table
    The portion of the query causing the issue is as follows:
    case
       when (T1.price is not null) then
             T1.price
       else
           T0.price
    end

    Hi Earl
    Seems you are right, I have tested with a few different formats and each time get a 2 decimal result. In SQL help I found the following which may explain why:
    Result Types
    Returns the highest precedence type from the set of types in result_expressions and the optional else_result_expression. For more information, see Data Type Precedence (Transact-SQL).
    Even tried it in SQL with a stored procedure storing to a temp table and it shows the full decimals, but executing the SP in SAP Business One results in 2 decimals again.
    This is indeed a strange occurrence and I a not sure how you are going to solve it! You can use NVARCHAR for example except that it right aligns the values returned, but at least it doesn't drop the decimals.
    Kind regards
    Peter Juby

  • HT1766 where can i see when the last back up occured on my iPhone?

    I know I can see the last back up that took place if I have my phone ... but is there a place to see when the last back up happened when I don't have access to my phone?

    Kappy wrote:
    Connect it to your computer, open iTunes, select the phone from
    How does he do that "when I don't have access to my phone", as he asked?

  • Need to call sap transaction when the work item got rejected.

    Hi all,
    I need to call the ME22n transaction once i reject the Work item. Once i press the rejection button on the work item it should direct to the sap transaction. how can i make this functionality in the decision task. Do i need to implement an ext for this.
    Thanks.
    Neslin.

    You simply create a task for executing the SAP transaction (business object TSTC)
    you use this task as a dialog step at the rejected outcome of the user decision with the same agent as the user decision and in the details of the workflow step you tick the advance with dialog box.
    And... you're done.
    Kind regards, Rob Dielemans
    Edit: Instead of using BO TSTC it would be better to check the BO normally related to Me22n and see if a dialog maintain method exists
    Edited by: Rob Dielemans on Jul 16, 2009 9:55 AM

  • How can I get a Quicktime update when the update states that an MSI for the previous version is missing

    How do you get a new version of Quicktime when it states that the msi for the old version is no longer available?

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATION" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up").
    In the list of programs that appears in CleanUp, select any QuickTime entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC. Now try another QuickTime install. Does it go through properly this time?

  • How to download ELEMENTS12 when the screen states incorrectly  configured

    I have  tried many,many times to download elements 12 but have had no luck so far. I have even had help from an expert . However, when I get  to the final screen it states that my computer is incorrectly configured! Where do I go to from here?

    Hi Mike,
    Please confirm what operating system you are using.
    Exact error meesage you are getting? Screenshot of the error message would be good.
    Please refer following forum thread in order post the screenshot.
    http://forums.adobe.com/thread/1070933
    Looking forward to your reply.
    Regards,
    Sumit Singh

  • What does it mean when the message states that "This accessory is not optimized for this Iphone"?

    Since Aug. 20th I have been receiving a message that states " This accessory is not optimized on this iphone", what does that mean, and how do I get id of it?

    If you don't have it plugged into something it means there is 'crud' in the dock connector causing a short and making it think there is something strange plugged in. Clean out the dock connector with a dry toothbrush.

Maybe you are looking for