Der vorliegende Artikel ist Teil einer Serie zum Thema Exception Handling. Mehr können Sie hier lesen:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
import java.util.List; | |
public class Example1 { | |
public static void main(String[] args) { | |
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6); | |
try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker logs nginx 2>&1 | grep "127." | |
# ref: http://stackoverflow.com/questions/34724980/finding-a-string-in-docker-logs-of-container |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### grep docker logs: | |
docker logs CONTAINER 2>&1 | grep "something" | |
### online liner commit running container, then squashed image: | |
docker save $(docker commit supatest supatest) | docker-squash -t supatest -verbose | docker load | |
### one liner to stop / remove all of Docker containers: | |
docker stop $(docker ps -a -q) | |
docker rm $(docker ps -a -q) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"meta": { | |
"theme": "elegant" | |
}, | |
"basics": { | |
"name": "Max Mustermann (EXAMPLE)", | |
"label": "Web Developer", | |
"image": "https://avatars0.githubusercontent.com/u/416209?s=460&u=38f220a2c9c658141804f881c334c594eb1642ac&v=4", | |
"summary": "I’m a full stack web developer who can build apps from the ground up. I've worked mostly at startups so I am use to wearing many hats. I am a very product focussed developer who priotizes user feedback first and foremost. I'm generally very flexible when investigating new roles. ", | |
"website": "https://ajaxdavis.com", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DirectoryBean workspaceRootDir; | |
try { | |
workspaceRootDir = (DirectoryBean) query.getSingleResult(); | |
} catch (NoResultException nre) { | |
if (create) { | |
// Workspace existiert nicht: anlegen! | |
workspaceRootDir = createWorkspaceRootDir(null, workspaceName, false); | |
} else { | |
throw new FileNotFoundException("Unknown workspace root: " + workspaceName); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Optional<DirectoryBean> workspaceRootDir = query.getResultList().stream().findFirst(); | |
if (workspaceRootDir.isEmpty()) { | |
if (create) { | |
// Workspace existiert nicht: anlegen! | |
workspaceRootDir = Optional.of(createWorkspaceRootDir(null, workspaceName, false)); | |
} else { | |
throw new FileNotFoundException("Unknown workspace root: " + workspaceName); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List queryResults = query.getResultList(); | |
if (queryResults.size() > 1) { | |
throw new NonUniqueResultException( | |
"Got multiple records with the same workspace root: " + workspaceName); | |
} | |
Optional<DirectoryBean> workspaceRootDir = queryResults.stream().findFirst(); | |
if (workspaceRootDir.isEmpty()) { | |
if (create) { |
Mehr zum Thema Tests können Sie hier lesen:
Mehr zum Thema Clean Code können Sie hier lesen:
OlderNewer