Skip to content

Conversation

@bernardnormier
Copy link
Member

This PR update the shutdown of the java/Ice/greeter demo to be more like the shutdown of demos in other languages.


package com.zeroc.demos.greeter;

import com.zeroc.demos.greeter.Chatbot;
Copy link
Member Author

Choose a reason for hiding this comment

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

Don't need import since Chatbot is in the same package.

}
}

private static void shutdownCommunicatorOnCtrlC(Communicator communicator, Thread cleanupThread) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't like cleanupThread name very much, what about using just mainThread?

Copy link
Member

@externl externl Mar 4, 2025

Choose a reason for hiding this comment

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

I also prefer mainThread.

It's not obvious from the name cleanupThread that your intention is that a user would do cleanup in the main thread, since we don't do any. It also seems to go against the convention in Java that you would do the cleanup in this hook.

Copy link
Member Author

Choose a reason for hiding this comment

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

since we don't do any.

We do perform cleanup in this thread: the cleanup is the destruction of the communicator that occurs at the end of the try-with-resources statement.

It also seems to go against the convention in Java that you would do the cleanup in this hook.

What do you suggest then?

This PR is all about NOT performing the cleanup in the hook, but waiting in the hook for some other thread (the cleanup thread) to complete the cleanup.

Copy link
Member

Choose a reason for hiding this comment

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

Like Jose suggested, I would just call it mainThread.

}
}

private static void shutdownCommunicatorOnCtrlC(Communicator communicator, Thread cleanupThread) {
Copy link
Member

@externl externl Mar 4, 2025

Choose a reason for hiding this comment

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

I also prefer mainThread.

It's not obvious from the name cleanupThread that your intention is that a user would do cleanup in the main thread, since we don't do any. It also seems to go against the convention in Java that you would do the cleanup in this hook.

### Windows

```shell
server\build\install\server\binserver

Choose a reason for hiding this comment

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

Just to answer your question, this is the default location where the application plugin we use puts these executables. Maybe we could tweak it, but this is the default.

If you're a normal Java developer, used to gradle, what you would expect to do is this:

./gradlew :server:run
./gradlew :client:run

And this does work, but it also outputs extra clutter which obscures what the demo is actually doing.

You can remove this clutter by running:

./gradlew :server:run --quiet
./gradlew :client:run --quiet

Which I think is slightly clearer than having to type out the paths directly.
So, I think we should switch to recommending these commands instead.

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 we change this because how Ctrl-C is handled by the scripts.

@bernardnormier bernardnormier merged commit a997166 into zeroc-ice:main Mar 4, 2025
7 checks passed
@bernardnormier bernardnormier deleted the java-greeter2 branch June 18, 2025 22:09
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.

4 participants