Skip to content

Correct null dereference exception on unusual import URIs #2429

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

Merged
merged 4 commits into from
Nov 17, 2020

Conversation

jcollins-g
Copy link
Contributor

@jcollins-g jcollins-g commented Nov 16, 2020

Fixes #2426.

BREAKING CHANGE for PackageGraph.allLibraries (change of key type).

Import URIs that resolve via unusual paths, but otherwise map to the "same" library, result in a null pointer exception when traversing the import/export graph. Fix this by forcing resolution to LibraryElements generated for the normalized URIs.

@google-cla google-cla bot added the cla: yes Google CLA check succeeded. label Nov 16, 2020
@jcollins-g jcollins-g changed the title Correct null pointer exception on unusual import URIs Correct null dereference exception on unusual import URIs Nov 16, 2020
@jcollins-g jcollins-g requested a review from srawlins November 16, 2020 23:24
@coveralls
Copy link

coveralls commented Nov 17, 2020

Coverage Status

Coverage increased (+0.01%) to 91.411% when pulling 8dd24bb on npe-importexportlib into 847121d on master.

@CaptainIRS
Copy link
Contributor

CaptainIRS commented Nov 17, 2020

I think it would be useful to emit a warning like the no-defining-library-found warning when an unusual URI is encountered.

PackageWarning.noDefiningLibraryFound: PackageWarningDefinition(
PackageWarning.noDefiningLibraryFound,
'no-defining-library-found',
'The defining library for an element could not be found; the library may '
'be imported or exported with a non-standard URI',
defaultWarningMode: PackageWarningMode.error),

return null;
}
var foundLibrary = Library.fromLibraryResult(
var foundLibrary;
foundLibrary = findButDoNotCreateLibraryFor(libraryElement);
Copy link
Member

Choose a reason for hiding this comment

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

Why declare this on line 891 and then initialize it on 892?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No good reason, I just rewrote these sections of code too many times working on this. Fixed.

@jcollins-g
Copy link
Contributor Author

I think it would be useful to emit a warning like the no-defining-library-found warning when an unusual URI is encountered.

PackageWarning.noDefiningLibraryFound: PackageWarningDefinition(
PackageWarning.noDefiningLibraryFound,
'no-defining-library-found',
'The defining library for an element could not be found; the library may '
'be imported or exported with a non-standard URI',
defaultWarningMode: PackageWarningMode.error),

I'm not entirely opposed to the idea, but I wonder if that might better belong in the linter. Filed as #2431.

@jcollins-g jcollins-g merged commit e9e2cfd into master Nov 17, 2020
@jcollins-g jcollins-g deleted the npe-importexportlib branch August 11, 2021 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Google CLA check succeeded.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE: importedExportedLibraries was called on null
4 participants