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

Fix NullPointerException when calling the EOModel.createPrototypeCache method from the wrong EOModel (take 2) #958

Merged

Conversation

hprange
Copy link
Contributor

@hprange hprange commented Oct 8, 2021

This error was first reported and fixed by the PR #551. One reason for this kind of error is the presence of duplicate NSBundles in the classpath. The previous fix prevented EOModels from the same NSBundle from being loaded twice.

There's another scenario, though, where the same issue may arise. If two distinct NSBundles have the same EOModel, the application may not initialize properly, throwing the exception below:

java.lang.NullPointerException
	at com.webobjects.eoaccess.EOModel.createPrototypeCache(EOModel.java:631)
	at com.webobjects.eoaccess.EOModel.prototypeAttributeNamed(EOModel.java:699)
	at com.webobjects.eoaccess.ERXModel.prototypeAttributeNamed(ERXModel.java:290)
	at com.webobjects.eoaccess.EOAttribute.<init>(EOAttribute.java:998)

This fix prevents EOModels with the same name from being loaded twice.

…e method from the wrong EOModel (take 2)

This error was first reported and fixed by the PR wocommunity#551. One reason for this kind of error is the presence of duplicate `NSBundles` in the classpath. The previous fix prevented EOModels from the same `NSBundle` from being loaded twice.

There's another scenario, though, where the same issue may arise. If two distinct `NSBundle`s have the same EOModel, the application may not initialize properly, throwing the exception below:

```
java.lang.NullPointerException
	at com.webobjects.eoaccess.EOModel.createPrototypeCache(EOModel.java:631)
	at com.webobjects.eoaccess.EOModel.prototypeAttributeNamed(EOModel.java:699)
	at com.webobjects.eoaccess.ERXModel.prototypeAttributeNamed(ERXModel.java:290)
	at com.webobjects.eoaccess.EOAttribute.<init>(EOAttribute.java:998)
```

This fix prevents EOModels with the same name from being loaded twice.
@hprange
Copy link
Contributor Author

hprange commented Oct 8, 2021

I cherry-picked this change into the wonder_6 branch. I've tested it with two apps: one using Wonder 7.x and the other using 6.x. No problems so far.

@paulhoadley paulhoadley self-requested a review January 7, 2022 00:32
Copy link
Contributor

@paulhoadley paulhoadley left a comment

Choose a reason for hiding this comment

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

While I haven't set up a test case which would be expected to fail without this change, I have tested this on two separate apps running Wonder 7.2. Both launch and run without issue.

@paulhoadley paulhoadley merged commit 72f7091 into wocommunity:master Jan 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants