Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
The various techniques used for maintaining stable program state in circumstances that, if not taken care of ("handled"), could cause serious issues, including logical bugs and abrupt execution termination.
1
vote
Map error messages to conditions
The following is what I consider an extension of @OldCurmudgeon's ansswer with three significant deviations/diclaimers:
It's uses Java 8's Stream and Predicate.
It turns your Response class into an …
3
votes
Verifying value before parsing
Short (and hopefully sweet) advice:
Are you able to modify parse() to throw a ParseException (I assuming you're talking about the linked one) if its argument is null? Something like:
String parse(Ob …
2
votes
Logging errors with the same exception type
Your log output shouldn't also be detailing the code that failed, because the JVM is going to generate a more detailed stacktrace, and you should print that instead.
LOGGER.error("..." + url, e);
I …
4
votes
Printing gitignores
Printing or writing .gitignore files?
Your title says printing, your description says writing, and your code seem to indicate you are merely creating a Map of directory, which has a .gitignore file, …
13
votes
Unbreakable average program
public static double userInput(String userInput){
// ...
if(userInput.matches("-?\\d+(\\.\\d+)?")){
// ...
} else {
System.err.println("ERROR: Non numeric input.Please chec …
3
votes
Accepted
Retry Runnable java
Defaulting to properties inside the Builder
You should perform validation inside the times(int), sleep(int) and on(Predicate) to either warn callers of invalid values, if not to throw an Exception. E …
1
vote
Recording a customer's shopping cart as an order 2.0
Maps
(copying my answer from another question):
A HashMap or ConcurrentHashMap (if you require the thread-safety) is preferred over the legacy Hashtable, as mentioned in the Javadoc:
As of the J …
1
vote
Accepted
Throwing exceptions if there is not exactly one box retrieved
Java 8
Optional<Box> maybe = boxDao.retrieve(boxIds.get(0));
if (maybe.isPresent()) {
return maybe.get();
}
// C
logger.warn("box not found");
throw new BoxNotFoundException();
If this is the …
5
votes
Layered architecture implementation in a Java web application
DAOFactory
public abstract class DAOFactory {
// List of DAO types supported by the factory
public static final int POSTGRESQL = 1;
public static final int ORACLE = 2;
...
}
Woah, …