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

NullPointer on inaccessible directories while searchRepositoriesSubfolders is true #347

Closed
gitblit opened this issue Aug 12, 2015 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@gitblit
Copy link
Owner

@gitblit gitblit commented Aug 12, 2015

Originally reported on Google Code with ID 51

What steps will reproduce the problem?
1. Configure gitblit to search repositories in subfolders
2. Create an inaccessible folder inside the repositoriesFolder
3. Start and try to browse.

It handles in this case a 'lost+found' folder owned by root. But it can be any folder
(just create a folder and chmod it to 000).

What is the expected output? What do you see instead?

ERROR Can't instantiate page using constructor public com.gitblit.wicket.pages.RepositoriesPage()
org.apache.wicket.WicketRuntimeException: Can't instantiate page using constructor
public com.gitblit.wicket.pages.RepositoriesPage()
....
Caused by: java.lang.NullPointerException
        at com.gitblit.utils.JGitUtils.getRepositoryList(JGitUtils.java:329)
        at com.gitblit.utils.JGitUtils.getRepositoryList(JGitUtils.java:345)
        at com.gitblit.utils.JGitUtils.getRepositoryList(JGitUtils.java:306)
        at com.gitblit.GitBlit.getRepositoryList(GitBlit.java:645)
        at com.gitblit.GitBlit.getRepositoryModels(GitBlit.java:699)
        at com.gitblit.wicket.pages.RootPage.getRepositoryFilterItems(RootPage.java:220)
        at com.gitblit.wicket.pages.RepositoriesPage.addDropDownMenus(RepositoriesPage.java:99)
        at com.gitblit.wicket.pages.RootPage.setupPage(RootPage.java:112)
        at com.gitblit.wicket.pages.RepositoriesPage.setup(RepositoriesPage.java:61)
        at com.gitblit.wicket.pages.RepositoriesPage.<init>(RepositoriesPage.java:47)
        ... 37 more

What version of the product are you using? On what operating system?

Version 0.8.2 GO version on Linux.

Please provide any additional information below.


Reported by lemval on 2012-01-30 14:09:51

@gitblit
Copy link
Owner Author

@gitblit gitblit commented Aug 12, 2015

Reported by James.Moger on 2012-01-30 14:28:45

  • Status changed: Accepted
  • Labels added: Milestone-0.9.0

@gitblit
Copy link
Owner Author

@gitblit gitblit commented Aug 12, 2015

1- In which directory have the gitblt?
2- With what command you call it?

Seems as if it created the folders to another directory that is not the source. Linux
distribution, there are a lot of, what is yours?

Thks

Reported by eguervos on 2012-01-30 20:32:43

@gitblit
Copy link
Owner Author

@gitblit gitblit commented Aug 12, 2015

Before answering your questions, I like to post the solution to this problem.

In file:
https://github.com/gitblit/gitblit/blob/master/src/com/gitblit/utils/JGitUtils.java
Method:
List<String> getRepositoryList(String basePath, File searchFolder, boolean exportAll,
boolean searchSubfolders)
On line:
} else if (searchSubfolders) {     --- 330 in github, 343 in google code, or the direct
link: http://code.google.com/p/gitblit/source/browse/src/com/gitblit/utils/JGitUtils.java#343

change this line to:
} else if (searchSubfolders && file.canRead()) {

This skips all directories which cannot be read. No sense in going deeper either.

----------
That said, the answer to your questions:
1. Linux version 2.6.32.24-0.2-default (geeko@buildhost) (gcc versio
n 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) x86_64 x86_64 x86_64 GNU/Linux
2. The error occurs on startup of gitlib when accessing the main page via https. No
repositories are shown.

I'm currently running a fixed version which seems to work fine.

Regards & thanks,
Michael

Reported by lemval on 2012-01-31 06:36:11

@gitblit
Copy link
Owner Author

@gitblit gitblit commented Aug 12, 2015

Hi Michael,
I understood your issue.  I can merge your change in GitHub if you open a pull request.
 If you'd rather not go through the bother, that is ok too.

-James

Reported by James.Moger on 2012-01-31 12:51:38

@gitblit
Copy link
Owner Author

@gitblit gitblit commented Aug 12, 2015

Quite easy as it seemed to aid you in a pull request. Here you are ;)

Reported by lemval on 2012-01-31 14:29:26

@gitblit
Copy link
Owner Author

@gitblit gitblit commented Aug 12, 2015

Perfect!  Thanks for the patch.

Reported by James.Moger on 2012-01-31 15:01:02

  • Status changed: Verified

@gitblit gitblit closed this as completed Aug 12, 2015
@flaix flaix added this to the 0.9.0 milestone Dec 13, 2016
@flaix flaix added this to the 0.9.0 milestone Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants