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

Improve workspace lock error dialog. #2347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raghucssit
Copy link
Contributor

Write workspace lock info like user, host, java process id, display properties onto .lock file if the lock was successful. Read the current lock data in case of lock was unsuccessful and shown it in error dialog.
If the .lock file has no info then nothing is shown. For older eclipse versions.

see #2343

@raghucssit
Copy link
Contributor Author

@iloveeclipse FYI

@BeckerWdf
Copy link
Contributor

Can you pls. provide a screenshot showing the new dialog?

@laeubi
Copy link
Contributor

laeubi commented Oct 1, 2024

By the way if on the lock dialog is worked, it would be great to have a cancel button!

Currently one can only Retry or Choose where on the second one can then finally cancel the startup of Eclipse. Instead I have most of the time not the case that another user locked the workspace but I have just an instance already running. In that case a early Cancel would be great.

@raghucssit
Copy link
Contributor Author

Can you pls. provide a screenshot showing the new dialog?

Dialog looks like this with this fix.
image

Write workspace lock info like user, host, java process id, display
properties onto .lock file if the lock was successful.
Read the current lock data in case of lock was unsuccessful and shown it
in error dialog.
If the .lock file has no info then nothing is shown. For older eclipse
versions.

see eclipse-platform#2343
Copy link
Contributor

github-actions bot commented Oct 1, 2024

Test Results

 1 815 files  ±0   1 815 suites  ±0   1h 34m 54s ⏱️ + 1m 12s
 7 702 tests ±0   7 462 ✅ +2  228 💤 ±0  1 ❌  - 1  11 🔥  - 1 
24 267 runs  ±0  23 508 ✅ +2  747 💤 ±0  1 ❌  - 1  11 🔥  - 1 

For more details on these failures and errors, see this check.

Results for commit f34d747. ± Comparison against base commit c9b34e4.

@BeckerWdf
Copy link
Contributor

Can you pls. provide a screenshot showing the new dialog?

Dialog looks like this with this fix. image

Maybe User, Host, etc. should be written in with an uppercase first letter (because they are some kind of label)

@tomaswolf
Copy link
Member

And these display strings must be localizeable.

Copy link
Member

@iloveeclipse iloveeclipse left a comment

Choose a reason for hiding this comment

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

Unfortunately it looks like writing to the locked file unlocks it again!

I'm able to start multiple Eclipse instances on same workspace now :-(

private String getHostName() {
String hostName = null;
try {
hostName = InetAddress.getLocalHost().getHostName();
Copy link
Member

Choose a reason for hiding this comment

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

I would prefer to check environment variable HOSTNAME first, because it doesn't do any network lookups and so is cheap on Linux.

See https://stackoverflow.com/questions/6050011/how-do-i-get-the-local-hostname-if-unresolvable-through-dns-in-java

props.load(is);
String prop = props.getProperty(USER);
if (prop != null) {
sb.append("user: ").append(prop).append(System.lineSeparator()); //$NON-NLS-1$
Copy link
Member

Choose a reason for hiding this comment

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

Could you please use IDEWorkbenchMessages so the strings could be translated if needed.

return null;
}

String displayText = "Workspace lock is held by the following owner:\n".concat(lockInfo); //$NON-NLS-1$
Copy link
Member

Choose a reason for hiding this comment

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

Please use IDEWorkbenchMessages here

*
* @return Previous lock owner details.
*/
private String getWorkspaceLockInfo(URL workspaceUrl) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please make this method and writeWsLockInfo() protected? This is not API, but we override parts of the class internally and these two methods most likely could need some customization sooner or later.


// make sure the directory exists
File metaDir = new File(workspaceUrl.getPath(), METADATA_FOLDER);
if (!metaDir.exists()) {
Copy link
Member

Choose a reason for hiding this comment

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

No need for extra folder check, file check below will do the job too

* @return Previous lock owner details.
*/
private String getWorkspaceLockInfo(URL workspaceUrl) {
File lockFile = getLockFile(workspaceUrl);
Copy link
Member

Choose a reason for hiding this comment

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

lockFile can be null.

* display and current java process id.
*/
private void writeWsLockInfo() {
Location instanceLoc = Platform.getInstanceLocation();
Copy link
Member

Choose a reason for hiding this comment

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

Please first create properties & fill with the data, and only if the properties are not empty, open file for writing.

String hostName = null;
try {
hostName = InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException e) {
Copy link
Member

Choose a reason for hiding this comment

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

to be consistent, I would also catch here generic Exception, just in case.

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.

5 participants