marykarthur2civ / maven-android-plugin

Automatically exported from code.google.com/p/maven-android-plugin
0 stars 0 forks source link

Null check after calling File.listFiles #236

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hello !

Recently, our builds stopped working on Jenkins. Here is the console output :

https://androidannotations.ci.cloudbees.com/job/AndroidAnnotations_CI/26/console

As you can see from the stacktrace, it seems that in some cases File.listFiles 
returns null, although File.isDirectory returned true, here :

https://github.com/jayway/maven-android-plugin/blob/master/src/main/java/com/jay
way/maven/plugins/android/AndroidSdk.java#L286

Our build is hosted on CloudBees, and I already reported the issue (might be an 
IO / storage issue, or something else, I don't really know).

If think there could be a null check, after calling File.listFiles. The Javadoc 
says this : "If this abstract pathname does not denote a directory, then this 
method returns null. Otherwise an array of File objects is returned, one for 
each file or directory in the directory. " However, after googling a bit, it 
seems that it may happen on some platforms that a File returns true to 
isDirectory but still returns null when calling File.listFiles (in case of IO 
problems, or secured access to files).

Version of the plugin : android-maven-plugin:3.0.0-alpha

Original issue reported on code.google.com by py.ricau on 29 Dec 2011 at 1:25

GoogleCodeExporter commented 9 years ago
I'm currently working with CloudBees support to fix this issue. It seems that 
they introduced a change to use a symlink for their Android SDK path, and...

http://stackoverflow.com/questions/2471805/listfiles-of-file-not-working-on-symb
olic-links

=> one should use getCanonicalFile() .

File directory = new File("/path/symlink/foo/bar").getCanonicalFile();
String[] files = directory.listFiles();

This is not yet certain, but if it proves right, maybe we should introduce this 
small change.

Original comment by py.ricau on 30 Dec 2011 at 8:24

GoogleCodeExporter commented 9 years ago
Sounds good. Want to come to a conclusion and send the pull request? I will 
merge and so on.. 

Original comment by mosa...@gmail.com on 13 Jan 2012 at 11:14

GoogleCodeExporter commented 9 years ago
Cloudbees found they had a permission issue in their r15 release, and after 
fixing that it worked again. I don't have the details, but I guess it means 
this shouldn't happen again.

I think this issue can be closed as "WontFix" or "Invalid". 

I don't know if you can access this, here is the ticket: 
https://cloudbees.zendesk.com/requests/2263

Thanks for answering anyway :)

Original comment by py.ricau on 14 Jan 2012 at 4:48

GoogleCodeExporter commented 9 years ago
Closing as requested

Original comment by mosa...@gmail.com on 16 Jan 2012 at 6:37