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

Downgrade ReadOnly Exception to warning #3299

Merged
merged 1 commit into from
Nov 18, 2024
Merged

Conversation

jukzi
Copy link
Contributor

@jukzi jukzi commented Nov 12, 2024

Throwing an Exception here currently causes more pain then just continuing.
Ideally one would rework the getter JavaProject.getResolvedClasspath() to never modify the javamodel, but it's not clear how todo that in a compatible way.

eclipse-jdt/eclipse.jdt.ui#1742

@@ -2022,7 +2023,9 @@ public void resetProjectCaches() {
*/
public void registerJavaModelDelta(IJavaElementDelta delta) {
if (JavaModelManager.isReadOnly()) {
throw new IllegalStateException("Its not allow to modify JavaModel during ReadOnly action. delta=" + delta); //$NON-NLS-1$
ILog.get().warn("JavaModel change during readOnly Operation", new IllegalStateException( //$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.

Sorry, that must be consistent: readOnly Operation -> 'read only' operation

@iloveeclipse
Copy link
Member

@jukzi : I assume we want this in 4.34 RC2? If so, @trancexpress please also review this PR.

Background: the feature eclipse-jdt/eclipse.jdt.ui#933 that added org.eclipse.jdt.internal.core.JavaModelManager.isReadOnly() and a hard check here caused a lot of regressions in related JDT/JDT UI code, last one is eclipse-jdt/eclipse.jdt.ui#1742.

So instead of hard failing with exception (and breaking caller code) this PR now allows operation but logs a warning.
From this point of view this shouldn't harm and should fix potential regressions introduced with the original change, therefore my assumption that it would be beneficial for 4.34 to have this PR merged.

@@ -2022,7 +2023,9 @@ public void resetProjectCaches() {
*/
public void registerJavaModelDelta(IJavaElementDelta delta) {
if (JavaModelManager.isReadOnly()) {
throw new IllegalStateException("Its not allow to modify JavaModel during ReadOnly action. delta=" + delta); //$NON-NLS-1$
ILog.get().warn("JavaModel change during read only Operation", new IllegalStateException( //$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.

Operation - > operation. Aller guten Dinge sind drei :-)

@jukzi
Copy link
Contributor Author

jukzi commented Nov 18, 2024

I assume we want this in 4.34 RC2

yes

@iloveeclipse
Copy link
Member

Jörg, the rules for capitalization rules in English are a bit different to German. TL;DR: first word in a sentence is capitalized, the rest is not, except in menus.

Throwing an Exception here currently causes more pain then just
continuing.
Ideally one would rework the getter JavaProject.getResolvedClasspath()
to never modify the javamodel, but it's not clear how todo that in a
compatible way.

eclipse-jdt/eclipse.jdt.ui#1742
throw new IllegalStateException("Its not allow to modify JavaModel during ReadOnly action. delta=" + delta); //$NON-NLS-1$
ILog.get().warn("JavaModel change during read only operation", new IllegalStateException( //$NON-NLS-1$
"JavaModel modified during 'read only' operation. Consider to report this warning to https://github.com/eclipse-jdt/eclipse.jdt.core/issues. delta=" //$NON-NLS-1$
+ delta));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we tell the user to report errors to github anywhere else in logged messages? if not I would omit this. Especially on a warning.

Maybe this should be an error though, considering we are expecting trouble to follow after this log (I assume caching somehow will go wrong?).

Copy link
Member

Choose a reason for hiding this comment

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

Do we tell the user to report errors to github anywhere else in logged messages? if not I would omit this. Especially on a warning.

In other places we've suggested to report to bugzilla, but that time is over :-)
And yes, it would make sense if users would report these warnings, so we can fix inappropriate code.

@jukzi jukzi merged commit 6b53bf4 into eclipse-jdt:master Nov 18, 2024
10 checks passed
@jukzi jukzi deleted the ReadOnly branch November 18, 2024 16:41
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