Skip to content

FileSize Hook: NullPointerException when size is null #43

@rubenanfinnes

Description

@rubenanfinnes

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://git@bitbucket.corp.com: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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions