NullPointerException if yaccHook is disabled in the global configuration

Description

The pre-receive repository hook can be disabled from the "Manage add-ons" page. If I do that, a NullPointerException is thrown:

```
2015-09-14 12:07:16,990 WARN [threadpool:thread-52] admin @6T5I3Hx727x15513x0 127.0.0.1 "POST /scm/val/repo1.git/git-receive-pack HTTP/1.1" c.a.s.i.h.DefaultBuiltInHookHandlerFactory PreReceiveHook failed, push will be rejected.
java.lang.NullPointerException: null
at com.isroot.stash.plugin.YaccPreReceiveHook.onReceive(YaccPreReceiveHook.java:59) ~[na:na]
at com.atlassian.stash.internal.hook.DefaultBuiltInHookHandlerFactory$1.handle(DefaultBuiltInHookHandlerFactory.java:45) ~[stash-service-impl-3.8.0.jar:na]
at com.atlassian.stash.internal.hook.DefaultHookService.doHandleRequest(DefaultHookService.java:345) [stash-service-impl-3.8.0.jar:na]
at com.atlassian.stash.internal.hook.DefaultHookService.handleRequest(DefaultHookService.java:331) [stash-service-impl-3.8.0.jar:na]
at com.atlassian.stash.internal.hook.DefaultHookService.handleRawRequest(DefaultHookService.java:239) [stash-service-impl-3.8.0.jar:na]
at com.atlassian.stash.internal.hook.DefaultHookService$2$1.run(DefaultHookService.java:205) [stash-service-impl-3.8.0.jar:na]
at com.atlassian.stash.internal.concurrent.StateTransferringExecutor$StateTransferringRunnable.run(StateTransferringExecutor.java:73) [stash-platform-3.8.0.jar:na]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_60]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_60]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_60]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0_60]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_60]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
... 1 frame trimmed
```

Fix: change line 59 in YaccPreReceiveHook to
if (hook != null && hook.isEnabled() && hook.isConfigured()) {

There should be a unit test too - unfortunately I am not familiar enough with mockito to submit a complete patch. I hope the bug report is helpful anyway.

YACC version 1.7.

Assignee

Unassigned

Reporter

Mohammed Davoodi

Sprint

None

Labels

Priority

Medium
Configure