Minimal code to reproduce:
<?php
file_put_contents("123", "Hello",LOCK_EX);
?>
Cause
java.lang.NullPointerException
com.caucho.quercus.lib.file.FileOutput.unlock(FileOutput.java:197)
com.caucho.quercus.lib.file.FileModule.flock(FileModule.java:1087)
com.caucho.quercus.lib.file.FileModule.file_put_contents(FileModule.java:1045)
I reviewed source code of quercus FileModule module and I am sure it happens because we close [B]os[/B], which is linked on the same object as s(BinaryOutput os = (BinaryOutput) s;) and after that we trying to make
flock(env, (LockableStream) s, LOCK_UN, null);
on that stream.IN file_put_contents function from FileModule