kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
172 stars 57 forks source link

Netbeans hangs when it exits. #344

Closed PavelSann closed 7 years ago

PavelSann commented 7 years ago

Netbeans hangs when it exits. In the tryGetLineSeparatorForTextFile method from the class java.org.netbeans.gradle.project.util.NbFileUtils.

1

It helps to delete files "gradle-app.setting" ".nb-gradle-properties" and folder ".nb-gradle"

PavelSann commented 7 years ago

Repeat on other projects failed. Perhaps the configuration files were from the old version or damaged.

kelemen commented 7 years ago

This is the shutdown hook trying to save the configurations.

If you look at that method in the sources, it does nothing fancy but reads the config file from the disk. So, it means that the file system does not answer for some reason (or is slow for something, maybe a slow network drive?).

Though I don't think I can fix this problem but I might mitigate it by being less aggressive when saving the configurations. I will see if there is anything I can do about that.

kelemen commented 7 years ago

It is possible that something is keeping this file open for writing and the read waits for new writes. What OS are you using?

PavelSann commented 7 years ago

OS windows 7, x64 The problem was repeated all the time, but only on one of the projects. I think it was the file that was to blame. I'm sorry I did not save it for tests.

kelemen commented 7 years ago

I seriously doubt that it is the content of the file, you may look at NbFileUtils.tryGetLineSeparatorForTextFile but it really just loops over a file stream, there is no compicated parsing here. If anything, then it was the location or that it was open for writting (with shared read).

PavelSann commented 7 years ago

Perhaps the method (tryGetLineSeparatorForTextFile) contains an eternal loop.

int readCount = input.read(buffer); while (readCount > 0) { ... input.read(buffer); }

14 июля 2017 г. 1:47 пользователь "Attila Kelemen" notifications@github.com написал:

This is the shutdown hook trying to save the configurations.

If you look at that method in the sources, it does nothing fancy but reads the config file from the disk. So, it means that the file system does not answer for some reason (or is slow for something, maybe a slow network drive?).

Though I don't think I can fix this problem but I might mitigate it by being less aggressive when saving the configurations. I will see if there is anything I can do about that.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kelemen/netbeans-gradle-project/issues/344#issuecomment-315197468, or mute the thread https://github.com/notifications/unsubscribe-auth/AK5M_yFXAdvTqk_wRbp0NNYjgyXGFZJ_ks5sNoJfgaJpZM4OWmNf .

kelemen commented 7 years ago

That would mean, that Files.newInputStream(file) (which is a core JDK method) returns an infinitely long file stream. Given that there are no infinitely long files, I doubt that, because that would be a huge bug in the JDK.

PavelSann commented 7 years ago

The readCount variable is set before the loop, it does not change in the body of the loop.

If more than 0 bytes are read from the file, the condition in "while (readCount> 0)" will always be true.

https://github.com/kelemen/netbeans-gradle-project/blob/v1.4.1/netbeans-gradle-plugin/src/main/java/org/netbeans/gradle/project/util/NbFileUtils.java#L43-L80

At the end of the cycle, "input.read (buffer)" is written. Probably it is necessary "readCount = input.read (buffer)"

16 июля 2017 г. 16:00 пользователь "Attila Kelemen" < notifications@github.com> написал:

That would mean, that Files.newInputStream(file) (which is a core JDK method) returns an infinitely long file stream. Given that there are no infinitely long files, I doubt that, because that would be a huge bug in the JDK.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kelemen/netbeans-gradle-project/issues/344#issuecomment-315601535, or mute the thread https://github.com/notifications/unsubscribe-auth/AK5M_xRUaKQsIrza9XdQVa7D64f-SPT1ks5sOe05gaJpZM4OWmNf .

kelemen commented 7 years ago

Thanks, I didn't even notice that the second read fails to set the readCount. I guess noone noticed this bug simply because the first line should always be shorter than 8 kB. This bug actually prevents saving settings until you close NB. I will fix it and will have a new release (fixing another bug).

kelemen commented 7 years ago

I have released a new version containing the fix of this bug. You can wait for it to be available in the plugins menu or install it manually (for the NB Plugin Portal page or from the releases page of GitHub).