Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: more wordsmithing, removed extraneous text from intro

Wiki Markup
            Some errors, such as out-of-range values, can be the result of erroneous user input. Interactive programs typically handle such errors by rejecting the input and prompting the user for an acceptable value. Servers reject invalid user input by indicating an error to the client while at the same continuing to respond to other clients. All robust programs must be prepared to gracefully handle resource exhaustion such as low memory or disk space conditions, at a minimum by preventing the loss of user data kept in volatile storage. Interactive programs may give the user the option to save data on an alternate medium, while network servers may respond by reducing throughput or otherwise degrading the quality of service.  However, whenWhen certain kinds of errors are detected, such as irrecoverable logic errors, rather than risk data corruption by continuing to execute in an indeterminate state, the appropriate strategy may be for the system to quickly shut down, allowing the operator to start it afresh in a determinate state.
\[[ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] Section 6.47, "REU Termination strategy," says:

...

This solution explicitly closes the file before exiting.

Code Block
bgColor#ccccff
public class CreateFile {
  public static void main(String[] args) throws FileNotFoundException {
    final PrintStream out = new PrintStream( new BufferedOutputStream(
                                        new FileOutputStream("foo.txt")));
    out.println("hello");
    out.close();
    Runtime.getRuntime().exit(1);
  }
}

...

Some precautions must be taken because the JVM is might be in a sensitive state during shutdown. Shutdown hook threads should:

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="53c3c1df962f9a06-d65ac00a-4bb046e4-895c946f-f84235f431a76334dc261536"><ac:plain-text-body><![CDATA[

[[MITRE 07

AA. Bibliography#MITRE 07]]

[CWE ID 705

http://cwe.mitre.org/data/definitions/705.html], "Incorrect Control Flow Scoping"

]]></ac:plain-text-body></ac:structured-macro>

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="09e40ba69f679350-ae1815e2-485241cd-84dfa11a-83a96accda8363f2f733b47c"><ac:plain-text-body><![CDATA[

[[ISO/IEC PDTR 24772

AA. Bibliography#ISO/IEC PDTR 24772]]

"REU Termination strategy"

]]></ac:plain-text-body></ac:structured-macro>

...