Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing throws Exception. Fixes #194 #200

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

honza-kasik
Copy link
Member

  • Not using throws Exception
  • Not using custom unchecked exception
  • Using unchecked exceptions as little as possible
  • Present a public interface for possible future extension (podman?)
  • Introducing several checked exceptions

Please make sure your PR meets the following requirements:

Copy link
Member

@mnovak1 mnovak1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@honza-kasik thanks, I have just a few tips to improve. There is a lot of code for exception handling but I understand the motivations.


public void start() throws Exception {
this.outputPrintingThread = startPrinterThread(dockerRunProcess, this.out, this.name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about to put this into finally {...} block to log output from starting process in case of fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you think about this one?

public boolean isRunning() {
Process dockerRunProcess;
try {
dockerRunProcess = new ProcessBuilder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that runDockerCommand() might be used here as well.

Process dockerInfoProcess = new ProcessBuilder()
.redirectErrorStream(true)
.command(new String[] { "docker", "info" })
.start();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that runDockerCommand() might be used here as well.

@mnovak1
Copy link
Member

mnovak1 commented Jan 27, 2020

@honza-kasik do you think that you might take a look at the test failures, I think they might be related to this PR

Edit: I've found the issue there is missing removeDockerContainer() in stop() and kill() methods.

@honza-kasik
Copy link
Member Author

@mnovak1 Exactly. I removed this calls because it didn't make sense to me. The problem is that the docker start command actually creates and starts container. Adding calls to these back to methods is IMHO a bad idea. I'll try to solve this...

@honza-kasik
Copy link
Member Author

@honza-kasik
Copy link
Member Author

@mnovak1 All green

.command(cmd)
.start();

process.waitFor(10, TimeUnit.SECONDS);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be removed here and leave to handle Process on calling method.

@@ -205,6 +205,7 @@ public void dropDatabaseSchema() {
public static void tearDown() throws Exception {
// stop DB if still running and delete data directory
postgresDB.stop();
postgresDB.remove();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think remove() should be called from stop() and kill() medhod...as this might be source of failures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue I see here is that the method called stop removes a container. That is IMHO not desired. What I have been thinking about is implementing Closable/AutoClosable interface to have a close method. Which would care about cleanup when the container is no longer needed. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found that there can be used --rm option in docker run... which causes that container is automatically removed when stopped (or killed) what about to use it and get rid of remove();

@honza-kasik
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants