-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Issue #12453 - Allow AnnotationParser to work with Resources types that do not support Path #12454
base: jetty-12.0.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,6 @@ protected Bundle getBundle(Resource resource) | |
public void parse(Set<? extends Handler> handlers, Bundle bundle) | ||
throws Exception | ||
{ | ||
|
||
Resource bundleResource = _bundleToResource.get(bundle); | ||
if (bundleResource == null) | ||
return; | ||
|
@@ -109,25 +108,28 @@ public void parse(final Set<? extends Handler> handlers, Resource r) throws Exce | |
if (!r.exists()) | ||
return; | ||
|
||
if (FileID.isJavaArchive(r.getPath())) | ||
{ | ||
parseJar(handlers, r); | ||
return; | ||
} | ||
|
||
if (r.isDirectory()) | ||
{ | ||
parseDir(handlers, r); | ||
return; | ||
} | ||
|
||
if (FileID.isClassFile(r.getPath())) | ||
else | ||
{ | ||
parseClass(handlers, null, r.getPath()); | ||
if (FileID.isJavaArchive(r.getFileName())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change in order? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make the conditions easier. Keeping the order it would have been ... if (!r.isDirectory() && FileID.isJavaArchive(r.getFileName()))
{
parseJar(handlers, r);
return;
}
if (r.isDirectory())
{
parseDir(handlers, r);
return;
}
if (!r.isDirectory() && FileID.isClassFile(r.getFileName()))
{
parseClass(handlers, null, r.getPath());
} Which reads really weird. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the point of this PR is just to add null protection, so I don't see how a change in the order of the way we consider what to do with a given resource is related. I don't like changing the well-established order of things unless there is an associated bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The NPE protection is just part of the change. |
||
{ | ||
parseJar(handlers, r); | ||
return; | ||
} | ||
|
||
if (FileID.isClassFile(r.getFileName())) | ||
{ | ||
parseClass(handlers, null, r); | ||
return; | ||
} | ||
} | ||
|
||
//Not already parsed, it could be a file that actually is compressed but does not have | ||
//.jar/.zip etc extension, such as equinox urls, so try to parse it | ||
// Not already parsed, it could be a file that actually is compressed but does not have | ||
// .jar/.zip etc extension, such as equinox urls, so try to parse it | ||
try | ||
{ | ||
parseJar(handlers, r); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need to change the established ordering: the change you've made just replaces
r.getPath()
withr.getFileName()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's far more subtle then that.
Path has knowledge of things like
.isFile
and.isRegularFile
and.isReadable
.String (from
r.getFileName
) does not, it's just a String.The original test
FileID.isClassFile(Path)
doesn't only check that the last Path segment text filename is a*.class
, but also checks if the provided Path is a file, not allowing directories with the name*.class
to pass as true.So, for example, the following change would need to be made at a minimum to maintain backward compatibility to the original code.
That would need to occur in at least two places.
Once you see that code, you'll quickly understand the order change.