Incorrect URI to File conversion in GenericExporter

Bug #755034 reported by cowwoc
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Querydsl
Fix Released
Undecided
Unassigned

Bug Description

GenericExporter converts a URI to a File incorrectly which causes it to fail under Windows. For example:

packagePath=/C:/Users/Gili/Documents/querydsl/trunk/querydsl-core/target/test-classes/com/mysema/query/codegen

(notice the leading slash)

but then later on:

child=C:\Users\Gili\Documents\querydsl\trunk\querydsl-core\target\test-classes\com\mysema\query\codegen\BeanSerializerTest.class

(notice the lack of leading slash)

So later on when you invoke "child.getPath().substring(packagePath.length()+1)" you're actually chopping off the first character of the filename.

To fix this bug simply replace:

                    packagePath = url.toURI().getPath();
                    files.add(new File(packagePath));

with

                    File packageAsFile = new File(url.toURI());
                    packagePath = packageAsFile.getPath();
                    files.add(packageAsFile);

Please also scan for similar instances of this bug in the rest of the codebase.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

I just commited this fix, could you retry?

Revision history for this message
cowwoc (gili) wrote :

Both revisions 13951 and 13952 work for me. I suggest you use File.getName() from r13951 because it's easier to read, and the URI to File fix from r13952 because of correctness.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Actually 13952 is probably the correct one, since the previous won't work for subpackages, but I will re-test.

Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Commited the final fix.

Changed in querydsl:
status: New → Fix Committed
Revision history for this message
Timo Westkämper (timo-westkamper) wrote :

Released in 2.2.0-beta4

Changed in querydsl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.