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 | ||
---|---|---|
| ||
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="b35184846170853d-9e3acaed-46cc4028-8efa9525-d1e7c6a1029dcb699d892bd5"><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="8f34547fd1b8070d-305ad14c-4d4c4d10-9f4fb782-a3e41a16ff3444469b053531"><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> |
...