-
Notifications
You must be signed in to change notification settings - Fork 27
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
FileSize Hook: NullPointerException when size is null #43
Comments
I am encountering the same issue as well with that same exception stack. Here's a repository that consistently fails when attempting to push with the filesize hook Fixes or workarounds would be appreciated. |
From what I can see in the code, it seems that when trying to get the map of the objects sizes, some of them have a null value. Cannot dig any further into this because this happens inside BitBucket which isn't OpenSource, unfortunately :-( We can avoid at least to crash the entire hook execution by just filtering out the incorrect null values. Going to propose a PR on this shortly. Luca |
Thanks for providing the PR. It is already merged and I will cut a new release in the next days. |
A new release 3.2.2 ia now available in the Atlassian Marketplace. |
Hi! We are still seeing this error after upgrading plugin to v3.3.2 and Bitbucket Server to v5.9.1. The developer of the project who has the repo experiencing the error say that it is only when committing the reference of a linked sub-module the error occurs, so might be a fringe use case. Just letting you know. The exception is: 2018-05-16 15:00:30,254 DEBUG [hook-callback:thread-2] user @1O0M7BMx900x21082309x2 12k1w1h 139.115.246.152 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git cat-file --batch-check |
NPE on submodule will be fixed via #54 |
One of our users has reported a NullPointerException when pushing to a repository with the FileSize Hook enabled:
$ git push origin feature/test
Enter passphrase for key '/c/Users/John.Doe/.ssh/id_rsa':
Counting objects: 17, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (17/17), done.
Writing objects: 100% (17/17), 1.32 KiB | 450.00 KiB/s, done.
Total 17 (delta 14), reused 0 (delta 0)
remote: Repository hook org.christiangalsterer.stash-filehooks-plugin:filesize-hook failed
remote: java.lang.NullPointerException
To ssh://bitbucket.corp.com:7999/project/repo.git
! [remote rejected] feature/test -> feature/test (pre-receive hook declined)
error: failed to push some refs to 'ssh://[email protected]:7999/project/repo.git'
From the logs, I can see the following:
2018-03-13 15:05:18,795 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git rev-list --format=%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct --no-min-parents --stdin --
2018-03-13 15:05:18,800 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git diff-tree -C -r --always --format=commit %H%n%H%x02%P%x02%aN%x02%aE%x02%at%x02%cN%x02%cE%x02%ct --root --stdin --
2018-03-13 15:05:18,803 DEBUG [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git cat-file --batch-check
2018-03-13 15:05:18,803 WARN [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.s.i.h.r.DefaultRepositoryHookService [PROJECT/repo[600]] Error calling com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate (org.christiangalsterer.stash-filehooks-plugin:filesize-hook)
java.lang.NullPointerException: null
at java.util.HashMap.merge(HashMap.java:1225)
at java.util.stream.Collectors.lambda$toMap$58(Collectors.java:1320)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1553)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.christiangalsterer.stash.filehooks.plugin.hook.CachingResolver.batchResolve(CachingResolver.java:87)
at org.christiangalsterer.stash.filehooks.plugin.hook.FileSizeHook.onReceive(FileSizeHook.java:82)
at com.atlassian.stash.internal.plugin.legacy.PreReceiveRepositoryHookAdapter.preUpdate(PreReceiveRepositoryHookAdapter.java:29)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.lambda$preUpdate$2(CompositeRepositoryHook.java:76)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.handlingExceptions(CompositeRepositoryHook.java:92)
at com.atlassian.stash.internal.plugin.legacy.CompositeRepositoryHook.preUpdate(CompositeRepositoryHook.java:75)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:798)
at com.atlassian.stash.internal.hook.repository.DefaultRepositoryHookService.preUpdate(DefaultRepositoryHookService.java:411)
at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory.lambda$preReceive$0(DefaultBuiltInHookHandlerFactory.java:36)
at com.atlassian.stash.internal.scm.git.GitQuarantineHelper.lambda$null$0(GitQuarantineHelper.java:89)
at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:303)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:289)
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:230)
at com.atlassian.stash.internal.hook.DefaultHookService$1.lambda$run$0(DefaultHookService.java:197)
at com.atlassian.stash.internal.concurrent.DefaultTransferableStateManager$StateTransferringRunnable.run(DefaultTransferableStateManager.java:166)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.lang.Thread.run(Thread.java:748)
... 26 frames trimmed
2018-03-13 15:05:18,804 INFO [threadpool:thread-1] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.s.i.h.r.DefaultRepositoryHookService [PROJECT/repo[600]] hook 'filesize-hook' vetoed the push request
2018-03-13 15:05:18,808 DEBUG [ssh-scm-request-handler] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.bitbucket.scm.BaseCommand Executed /usr/bin/git receive-pack /data/bitbucket/5.6.2/data/shared/data/repositories/600
2018-03-13 15:05:18,808 DEBUG [ssh-scm-request-handler] @1BHS7ZCx905x4593074x1 emf92j 192.168.1.1 SSH - git-receive-pack '/project/repo.git' c.a.b.scm.ssh.SshCommandExitHandler /usr/bin/git receive-pack /data/bitbucket/5.6.2/data/shared/data/repositories/600: (Exit code: 0)
We are running Bitbucket Server 5.6.2 and File Hooks plugin v3.3.1. I think this is possibly a repository-related issue as we have the File Size Hook enabled in 200+ repos and this is the only repos so far to report the problem. Have disabled the hook in this repo for now, but would be nice to understand what causes this as we appreciate the functionality the hook offers.
Any thoughts or suggestions appreciated.
The text was updated successfully, but these errors were encountered: